Table of Contents

Class LoopNetClient

Namespace
LoopNet.Services
Assembly
LoopNet.dll

The LoopNet Client class

public class LoopNetClient : ILoopNetClient, IDisposable
Inheritance
LoopNetClient
Implements
Inherited Members

Methods

CreateLoopNetClientAsync(int, string, string, bool)

Creates an instance of the LoopNet client. This will also generate the Loopring L2 Private Key and retrieve the Loopring API Key.

public static Task<LoopNetClient> CreateLoopNetClientAsync(int chainId, string l1PrivateKey, string ethAddress, bool showConnectionInfo = false)

Parameters

chainId int

1 for MAINNET, 5 for Test

l1PrivateKey string

The L1 Private Key

ethAddress string

The Eth address associated with the L1 Private Key in Ox format

showConnectionInfo bool

Indicates whether to display the connection info. Optional, defaults to false.

Returns

Task<LoopNetClient>

A LoopNetClient

Dispose()

Disposes the LoopNet client

public void Dispose()

GetAccountInformationAsync(string)

Gets account information

public Task<AccountInformationResponse?> GetAccountInformationAsync(string owner)

Parameters

owner string

The address to retrieve account information from

Returns

Task<AccountInformationResponse>

The account information

Exceptions

Exception

Thrown when there is an issue with the Loopring API, most likey the address does not exist on Loopring

GetCounterFactualNftTokenAddressAsync(CounterFactualNftInfo)

Get the counterfactual nft token address

public Task<CounterFactualNft?> GetCounterFactualNftTokenAddressAsync(CounterFactualNftInfo counterFactualNftInfo)

Parameters

counterFactualNftInfo CounterFactualNftInfo

The Counterfactual NFT info

Returns

Task<CounterFactualNft>

The counterfactual nft token address

Exceptions

Exception

Thrown when there is an issue with the Loopring API

GetExchangeTokensAsync()

Gets the exchange tokens

public Task<List<ExchangeTokenResponse>?> GetExchangeTokensAsync()

Returns

Task<List<ExchangeTokenResponse>>

The exchange tokens

Exceptions

Exception

Thrown when there is an issue with the Loopring API

GetMarketsAsync()

Gets the markets

public Task<MarketsResponse?> GetMarketsAsync()

Returns

Task<MarketsResponse>

The markets

Exceptions

Exception

Thrown when there is an issue with the Loopring API

GetNftCollectionInfoAsync(string)

Gets information on an nft collection

public Task<GetNftCollectionInfoResponse?> GetNftCollectionInfoAsync(string tokenAddress)

Parameters

tokenAddress string

The token address

Returns

Task<GetNftCollectionInfoResponse>

The nft collection result

Exceptions

Exception

Thrown when there is an issue with the Loopring API

GetNftHoldersAsync(string)

Gets the nft holders for a given nftData

public Task<List<NftHolder>?> GetNftHoldersAsync(string nftData)

Parameters

nftData string

The nftData

Returns

Task<List<NftHolder>>

A list of holders for the given nftData

Exceptions

Exception

Thrown when there is an issue with the Loopring API

GetNftOffChainFeeWithAmountAsync(int, int, string)

Get nft offchain fee with amount

public Task<OffchainFeeResponse?> GetNftOffChainFeeWithAmountAsync(int amount, int requestType, string tokenAddress)

Parameters

amount int

The amount

requestType int

The request type

tokenAddress string

The token address

Returns

Task<OffchainFeeResponse>

The nft offchain fee with amount

Exceptions

Exception

Thrown when there is an issue with the Loopring API

GetNftTokenIdAsync(string)

Get the NFT balance info

public Task<NftBalanceResponse?> GetNftTokenIdAsync(string nftData)

Parameters

nftData string

The nftData in 0x format, ie 0x2a212b36db36d229d3ee5690c7f9fe0099b53d6f05cfb0349060f4c18012a664

Returns

Task<NftBalanceResponse>

The NFT balance info

Exceptions

Exception

Thrown when there is an issue with the Loopring API, possibly nftData doesnt exist in your wallet

GetNftWalletBalanceAsync(int?)

Gets the nft balance of a wallet

public Task<Dictionary<string, Datum>?> GetNftWalletBalanceAsync(int? acccountId = null)

Parameters

acccountId int?

The account id of the wallet. Optional, defaults to own wallet

Returns

Task<Dictionary<string, Datum>>

A dictionary with keys being nftData and value being the nft balance info details

Exceptions

Exception

Thrown when there is an issue with the Loopring API, if accountId does not exist

GetOffChainFeeWithAmountAsync(int, int, int)

Get offchain fee with amount

public Task<OffchainFeeResponse?> GetOffChainFeeWithAmountAsync(int amount, int requestType, int extraType)

Parameters

amount int

The amount

requestType int

The request type

extraType int

The extra type

Returns

Task<OffchainFeeResponse>

The offchain fee with amount

Exceptions

Exception

Thrown when there is an issue with the Loopring API

GetOffchainFeeAsync(int, string, string)

Gets offchain fee

public Task<OffchainFeeResponse?> GetOffchainFeeAsync(int requestType, string feeToken, string amount)

Parameters

requestType int

The request type

feeToken string

The fee token, ie LRC

amount string

The amount

Returns

Task<OffchainFeeResponse>

The offchain fee

Exceptions

Exception

Thrown when there is an issue with the Loopring API, most likey the fee token or request type doest not exist

GetOffchainFeeNftAsync(int, string)

Gets the offchain fee for an nft request

public Task<OffchainFeeResponse?> GetOffchainFeeNftAsync(int requestType, string tokenAddress)

Parameters

requestType int

The request type

tokenAddress string

The token address

Returns

Task<OffchainFeeResponse>

The offchain fee for an nft request

Exceptions

Exception

Thrown when there is an issue with the Loopring API

GetOffchainFeeNftTransferAsync(int, string)

Gets the offchain fee for an nft transfer request

public Task<OffchainFeeResponse?> GetOffchainFeeNftTransferAsync(int requestType, string amount)

Parameters

requestType int

The request type

amount string

The amount

Returns

Task<OffchainFeeResponse>

The offchain fee for an nft transfer request

Exceptions

Exception

Thrown when there is an issue with the Loopring API

GetOrderUserRateAmountAsync(string)

Gets the order user rate amounts

public Task<OrderUserRateAmountResponse?> GetOrderUserRateAmountAsync(string market)

Parameters

market string

The market, ie LRC-ETH

Returns

Task<OrderUserRateAmountResponse>

The order user rate amounts

Exceptions

Exception

Thrown when there is an issue with the Loopring API

GetStorageIdAsync(int)

Gets storage id

public Task<StorageIdResponse?> GetStorageIdAsync(int sellTokenId)

Parameters

sellTokenId int

The sell token id

Returns

Task<StorageIdResponse>

The storage id

Exceptions

Exception

Thrown when there is an issue with the Loopring API, most likey the sellTokenId does not exist

GetTickersAsync(string)

Gets tickers.

public Task<TickersResponse?> GetTickersAsync(string pairs)

Parameters

pairs string

A comma seperated list of pairs, ie: LRC-ETH,LRC-WBTC

Returns

Task<TickersResponse>

The tickers

Exceptions

Exception

Thrown when there is an issue with the Loopring API, most likey one of the pairs do not exist

GetWalletCounterFactualInfoAsync(int)

Gets the counterfactual info for a wallet

public Task<CounterFactualWalletInfoResponse?> GetWalletCounterFactualInfoAsync(int accountId)

Parameters

accountId int

The account id of the wallet

Returns

Task<CounterFactualWalletInfoResponse>

The wallet type

Remarks

This method returns null if the wallet counterfactual info can not be found

GetWalletTypeAsync(string)

Gets the wallet type

public Task<WalletTypeResponse?> GetWalletTypeAsync(string walletAddress)

Parameters

walletAddress string

The wallet address in 0x format.

Returns

Task<WalletTypeResponse>

The wallet type

Exceptions

Exception

Thrown when there is an issue with the Loopring API

PostLegacyMintNft(string, int, int, string, string?)

Post the nft mint to the legacy nft factory contract

public Task<PostNftMintResponse?> PostLegacyMintNft(string ipfsMetadataJsonCidv0, int numberOfEditions, int royaltyPercentage, string tokenFeeSymbol, string? royaltyAddress = null)

Parameters

ipfsMetadataJsonCidv0 string

The IPFS metadata json in CIDv0 format, ie starts with Qm

numberOfEditions int

The number of editions, Set to 1 for 1 edition, 2 for 2 editions and etc

royaltyPercentage int

The royalty percantage, a whole number between 0 to 10

tokenFeeSymbol string

The token symbol for the fees, can be LRC or ETH

royaltyAddress string

The royalty address in 0x format, Optional. Only set if you want royalties go a different address than yourself

Returns

Task<PostNftMintResponse>

The Nft Mint Response

Exceptions

Exception

Thrown when there is an issue with the Loopring API, such as duplicate nft mints

PostMintRedPacketAsync(long, long, RedPacketType, RedPacketViewType, RedPacketAmountType, int, decimal, decimal, string, string, decimal?)

Post mint red packet

public Task<RedPacketMintResponse?> PostMintRedPacketAsync(long validSince, long validUntil, RedPacketType redPacketType, RedPacketViewType redPacketViewType, RedPacketAmountType redPacketAmountType, int tokenToSend, decimal amountPerPacket, decimal amountOfPackets, string memo, string feeTokenSymbol, decimal? giftAmount = null)

Parameters

validSince long

The date when the red packet can be started to claim. Unix Timestamp in seconds in UTC

validUntil long

The date when the red packet claim ends. Unix Timestamp in seconds in UTC

redPacketType RedPacketType

The red packet type

redPacketViewType RedPacketViewType

The red packet view type public, private or exclusive

redPacketAmountType RedPacketAmountType

The red packet amount distribution type.

tokenToSend int

The token id of the token to send. 0 for eth, 1 for lrc

amountPerPacket decimal

Amount per packets

amountOfPackets decimal

Amount of packets

memo string

The memo to include

feeTokenSymbol string

The fee token symbol

giftAmount decimal?

Amount to gift if blind box nft, optional

Returns

Task<RedPacketMintResponse>

The red packet mint response

Exceptions

Exception

Thrown when there is an issue with the Loopring API

PostNftMintAsync(string, string, int, int, string, string?)

Post the nft mint to the current nft factory contract

public Task<PostNftMintResponse?> PostNftMintAsync(string contractAddress, string ipfsMetadataJsonCidv0, int numberOfEditions, int royaltyPercentage, string tokenFeeSymbol, string? royaltyAddress = null)

Parameters

contractAddress string

The contract address of the collection in 0x format

ipfsMetadataJsonCidv0 string

The IPFS metadata json in CIDv0 format, ie starts with Qm

numberOfEditions int

The number of editions, Set to 1 for 1 edition, 2 for 2 editions and etc

royaltyPercentage int

The royalty percantage, a whole number between 0 to 10

tokenFeeSymbol string

The token symbol for the fees, can be LRC or ETH

royaltyAddress string

The royalty address in 0x format, Optional. Only set if you want royalties go a different address than yourself

Returns

Task<PostNftMintResponse>

The Nft Mint Response

Exceptions

Exception

Thrown when there is an issue with the Loopring API, such as duplicate nft mints

PostNftMintRedPacketAsync(long, long, RedPacketType, RedPacketViewType, RedPacketAmountType, string, string, string, string, string, string?)

Post nft mint red packet

public Task<RedPacketMintResponse?> PostNftMintRedPacketAsync(long validSince, long validUntil, RedPacketType nftRedPacketType, RedPacketViewType nftRedPacketViewType, RedPacketAmountType nftRedPacketAmountType, string nftData, string amountOfNftsPerPacket, string amountOfPackets, string memo, string feeTokenSymbol, string? giftAmount = null)

Parameters

validSince long

The date when the red packet can be started to claim. Unix Timestamp in seconds in UTC

validUntil long

The date when the red packet claim ends. Unix Timestamp in seconds in UTC

nftRedPacketType RedPacketType

The nft red packet type

nftRedPacketViewType RedPacketViewType

The nft red packet view type public, private or exclusive

nftRedPacketAmountType RedPacketAmountType

The nft red packet amount distribution type.

nftData string

The nft data

amountOfNftsPerPacket string

Amount of nfts per packets

amountOfPackets string

Amount of packets

memo string

The memo to include

feeTokenSymbol string

The fee token symbol

giftAmount string

Amount to gift if blind box nft, optional

Returns

Task<RedPacketMintResponse>

The red packet mint response

Exceptions

Exception

Thrown when there is an issue with the Loopring API

PostNftTransferAsync(string, string, int, string, string, bool)

Transfers a nft to an address

public Task<TransferTokenResponse?> PostNftTransferAsync(string toAddress, string nftData, int amountOfEditionsToTransfer, string feeTokenSymbol, string memo, bool payAccountActivationFee = false)

Parameters

toAddress string

The address to transfer the NFT to in 0x format

nftData string

The nftData in 0x format

amountOfEditionsToTransfer int

The amount of editions to transfer

feeTokenSymbol string

The token symbol to pay fees in, ie Only works with ETH or LRC

memo string

The memo to send,

payAccountActivationFee bool

Whether you want to pay the toAddress account activation fee. Optional, Defaults to false

Returns

Task<TransferTokenResponse>

The transfer token reponnse

Exceptions

Exception

Thrown when there is an issue with the Loopring API, could be due to a number of issues such as storageId, offchainFee or not having enough balance of the transfer token

PostOrderAsync(Token, Token, bool, bool, int, int, string?, OrderType?, TradeChannel?, string?, string?, string?)

Post an order to exchange two currencies

public Task<OrderResponse?> PostOrderAsync(Token sellToken, Token buyToken, bool allOrNone, bool fillAmountBOrS, int validUntil, int maxFeeBips = 20, string? clientOrderId = null, OrderType? orderType = null, TradeChannel? tradeChannel = null, string? taker = null, string? poolAddress = null, string? affiliate = null)

Parameters

sellToken Token

The token you are selling

buyToken Token

The token you are buying

allOrNone bool

Whether the order supports partial fills or not.Currently only supports false as a valid value

fillAmountBOrS bool

Fill size by buy token or by sell token

validUntil int

Order expiration time, accuracy is in seconds

maxFeeBips int

Maximum order fee that the user can accept, value range (in ten thousandths) 1 ~ 63

clientOrderId string

An arbitrary, client-set unique order identifier, max length is 120 bytes

orderType OrderType?

Order types, can be AMM, LIMIT_ORDER, MAKER_ONLY, TAKER_ONLY

tradeChannel TradeChannel?

Order channel, can be BLANK,ORDER_BOOK, AMM_POOL, MIXED

taker string

Used by the P2P order which user specify the taker, so far its 0x0000000000000000000000000000000000000000

poolAddress string

The AMM pool address if order type is AMM

affiliate string

An accountID who will recieve a share of the fee of this order

Returns

Task<OrderResponse>

The order response

Exceptions

Exception

Thrown when there is an issue with the Loopring API, such as an invalid order

PostRedPacketTargetAsync(List<string>, string, int)

Post red packet target to a list of addressess

public Task<TransferTokenResponse?> PostRedPacketTargetAsync(List<string> addresses, string nftRedPacketHash, int notifyType)

Parameters

addresses List<string>

The list of address to send the nft red packet to

nftRedPacketHash string
notifyType int

Notification type, 0 for badge, 1 for push notification

Returns

Task<TransferTokenResponse>

PostTokenTransferAsync(string, string, decimal, string, string, bool)

Transfers a token to an address

public Task<TransferTokenResponse?> PostTokenTransferAsync(string toAddress, string transferTokenSymbol, decimal tokenAmount, string feeTokenSymbol, string memo, bool payAccountActivationFee = false)

Parameters

toAddress string

The address to transfer the token to in 0x format

transferTokenSymbol string

The token symbol to transfer, Only works with ETH or LRC

tokenAmount decimal

The amount of the transfer token to sell in decimals, ie 0.1m

feeTokenSymbol string

The token symbol to pay fees in, ie Only works with ETH or LRC

memo string

The memo to send,

payAccountActivationFee bool

Whether you want to pay the toAddress account activation fee. Optional, Defaults to false

Returns

Task<TransferTokenResponse>

The transfer token reponnse

Exceptions

Exception

Thrown when there is an issue with the Loopring API, could be due to a number of issues such as storageId, offchainFee or not having enough balance of the transfer token