Class LoopNetClient
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
int1 for MAINNET, 5 for Test
l1PrivateKey
stringThe L1 Private Key
ethAddress
stringThe Eth address associated with the L1 Private Key in Ox format
showConnectionInfo
boolIndicates 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
stringThe 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
CounterFactualNftInfoThe 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
stringThe 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
stringThe nftData
Returns
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
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
stringThe 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
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
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
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
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
stringThe 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
intThe 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
stringA 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
intThe 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
stringThe 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
stringThe IPFS metadata json in CIDv0 format, ie starts with Qm
numberOfEditions
intThe number of editions, Set to 1 for 1 edition, 2 for 2 editions and etc
royaltyPercentage
intThe royalty percantage, a whole number between 0 to 10
tokenFeeSymbol
stringThe token symbol for the fees, can be LRC or ETH
royaltyAddress
stringThe 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
longThe date when the red packet can be started to claim. Unix Timestamp in seconds in UTC
validUntil
longThe date when the red packet claim ends. Unix Timestamp in seconds in UTC
redPacketType
RedPacketTypeThe red packet type
redPacketViewType
RedPacketViewTypeThe red packet view type public, private or exclusive
redPacketAmountType
RedPacketAmountTypeThe red packet amount distribution type.
tokenToSend
intThe token id of the token to send. 0 for eth, 1 for lrc
amountPerPacket
decimalAmount per packets
amountOfPackets
decimalAmount of packets
memo
stringThe memo to include
feeTokenSymbol
stringThe 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
stringThe contract address of the collection in 0x format
ipfsMetadataJsonCidv0
stringThe IPFS metadata json in CIDv0 format, ie starts with Qm
numberOfEditions
intThe number of editions, Set to 1 for 1 edition, 2 for 2 editions and etc
royaltyPercentage
intThe royalty percantage, a whole number between 0 to 10
tokenFeeSymbol
stringThe token symbol for the fees, can be LRC or ETH
royaltyAddress
stringThe 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
longThe date when the red packet can be started to claim. Unix Timestamp in seconds in UTC
validUntil
longThe date when the red packet claim ends. Unix Timestamp in seconds in UTC
nftRedPacketType
RedPacketTypeThe nft red packet type
nftRedPacketViewType
RedPacketViewTypeThe nft red packet view type public, private or exclusive
nftRedPacketAmountType
RedPacketAmountTypeThe nft red packet amount distribution type.
nftData
stringThe nft data
amountOfNftsPerPacket
stringAmount of nfts per packets
amountOfPackets
stringAmount of packets
memo
stringThe memo to include
feeTokenSymbol
stringThe fee token symbol
giftAmount
stringAmount 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
stringThe address to transfer the NFT to in 0x format
nftData
stringThe nftData in 0x format
amountOfEditionsToTransfer
intThe amount of editions to transfer
feeTokenSymbol
stringThe token symbol to pay fees in, ie Only works with ETH or LRC
memo
stringThe memo to send,
payAccountActivationFee
boolWhether 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
TokenThe token you are selling
buyToken
TokenThe token you are buying
allOrNone
boolWhether the order supports partial fills or not.Currently only supports false as a valid value
fillAmountBOrS
boolFill size by buy token or by sell token
validUntil
intOrder expiration time, accuracy is in seconds
maxFeeBips
intMaximum order fee that the user can accept, value range (in ten thousandths) 1 ~ 63
clientOrderId
stringAn 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
stringUsed by the P2P order which user specify the taker, so far its 0x0000000000000000000000000000000000000000
poolAddress
stringThe AMM pool address if order type is AMM
affiliate
stringAn 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
stringnotifyType
intNotification type, 0 for badge, 1 for push notification
Returns
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
stringThe address to transfer the token to in 0x format
transferTokenSymbol
stringThe token symbol to transfer, Only works with ETH or LRC
tokenAmount
decimalThe amount of the transfer token to sell in decimals, ie 0.1m
feeTokenSymbol
stringThe token symbol to pay fees in, ie Only works with ETH or LRC
memo
stringThe memo to send,
payAccountActivationFee
boolWhether 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