IMX Provider
A provider is an interface for abstracting the user's wallet implementation from the application, which enables the development of wallet-agnostic applications.
For the Immutable StarkEx network, Immutable has defined a Provider interface incorporating the IMX-specific signable actions, such as creating an order, withdrawals, and more.
The following list details all the signable actions supported by the IMX Provider along with definitions of the request and response payloads.
IMXProvider Methods
- batchNftTransfer
- cancelOrder
- completeWithdrawal
- createOrder
- createTrade
- deposit
- exchangeTransfer
- getAddress
- isRegisteredOnchain
- prepareWithdrawal
- isRegisteredOffchain
- registerOffchain
- transfer
Method Details
batchNftTransfer
▸ batchNftTransfer(request): Promise<CreateTransferResponse>
Create a batch of NFT transfer requests
Parameters
| Name | Type | Description |
|---|---|---|
request | NftTransferDetails[] | An array of NFT transfer details |
Limitation: less than 40 nfts/request
Returns
Promise<CreateTransferResponse>
Resolves a promise that resolves with the list of Transfer IDs
Defined in
src/modules/provider/imxProvider.ts:73
cancelOrder
▸ cancelOrder(request): Promise<CancelOrderResponse>
Cancel an Order or Offer
Parameters
| Name | Type | Description |
|---|---|---|
request | GetSignableCancelOrderRequest | The signable cancel order request |
Returns
Promise<CancelOrderResponse>
Returns a promise that resolves with the cancelled Order
Defined in
src/modules/provider/imxProvider.ts:52
completeWithdrawal
▸ completeWithdrawal(starkPublicKey, token): Promise<TransactionResponse>
Completes a Withdrawal
Parameters
| Name | Type | Description |
|---|---|---|
starkPublicKey | string | The stark public key |
token | AnyToken | The token to withdraw |
Returns
Promise<TransactionResponse>
Returns a promise that resolves with the transaction
Defined in
src/modules/provider/imxProvider.ts:102
createOrder
▸ createOrder(request): Promise<CreateOrderResponse>
The function used to create an Order or make an Offer
Parameters
| Name | Type | Description |
|---|---|---|
request | UnsignedOrderRequest | The unsigned order request to create an order, or make an offer |
Returns
Promise<CreateOrderResponse>
Returns a promise that resolves with the created Order
Defined in
src/modules/provider/imxProvider.ts:45
createTrade
▸ createTrade(request): Promise<CreateTradeResponse>
Create a Trade or Accept an Offer
Parameters
| Name | Type | Description |
|---|---|---|
request | GetSignableTradeRequest | The signable trade request |
Returns
Promise<CreateTradeResponse>
Returns a promise that resolves with the created Trade
Defined in
src/modules/provider/imxProvider.ts:59
deposit
▸ deposit(deposit): Promise<TransactionResponse>
Deposit either ETH, ERC20 or ERC721 tokens
Parameters
| Name | Type |
|---|---|
deposit | TokenAmount |
Returns
Promise<TransactionResponse>
Returns a promise that resolves with the transaction
Defined in
src/modules/provider/imxProvider.ts:87
exchangeTransfer
▸ exchangeTransfer(request): Promise<CreateTransferResponseV1>
Create a new Exchange transaction
Parameters
| Name | Type | Description |
|---|---|---|
request | UnsignedExchangeTransferRequest | The unsigned exchange transfer request |
Returns
Promise<CreateTransferResponseV1>
Returns a promise that resolves with the created Exchange Transaction
Defined in
src/modules/provider/imxProvider.ts:80
getAddress
▸ getAddress(): Promise<string>
Get the Signer address
Returns
Promise<string>
Returns a promise that resolves with the signer's address
Defined in
src/modules/provider/imxProvider.ts:26
isRegisteredOnchain
▸ isRegisteredOnchain(): Promise<boolean>
Checks if a User is registered on-chain
Returns
Promise<boolean>
Returns a promise that resolves with true if the User is registered, false otherwise
Defined in
src/modules/provider/imxProvider.ts:38
prepareWithdrawal
▸ prepareWithdrawal(request): Promise<CreateWithdrawalResponse>
Create a Withdrawal
Parameters
| Name | Type | Description |
|---|---|---|
request | TokenAmount | The token type amount in its corresponding unit |
Returns
Promise<CreateWithdrawalResponse>
Returns a promise that resolves with the created Withdrawal
Defined in
src/modules/provider/imxProvider.ts:94
isRegisteredOffchain
▸ isRegisteredOffchain(): Promise<boolean>
Checks if a User is registered off-chain
Returns
Promise<boolean>
Returns a promise that resolves with true if the User is registered with Immutable X, false otherwise
Defined in
src/modules/provider/imxProvider.ts:38
registerOffchain
▸ registerOffchain(): Promise<RegisterUserResponse>
Register a User to Immutable X if they are not already registered
Returns
Promise<RegisterUserResponse>
Returns a promise that resolves with the user registration response
Defined in
src/modules/provider/imxProvider.ts:32
transfer
▸ transfer(request): Promise<CreateTransferResponseV1>
Create a new Transfer request
Parameters
| Name | Type | Description |
|---|---|---|
request | UnsignedTransferRequest | The unsigned transfer request |
Returns
Promise<CreateTransferResponseV1>
Returns a promise that resolves with the created Transfer
Defined in
src/modules/provider/imxProvider.ts:66
Types
AnyToken
| Name | Type | Description |
|---|---|---|
token | ETHToken | ERC721Token | ERC20Token | ID of the cancelled order |
EthToken
An ETH token
| Name | Type | Description |
|---|---|---|
Type | "ETH" | The string literal "ETH" |
ERC721Token
An ERC721 token
| Name | Type | Description |
|---|---|---|
tokenAddress | string | The token address |
tokenId | string | The token ID |
type | "ERC721" | The string literal "ERC721" |
ERC20Token
An ERC20 token
| Name | Type | Description |
|---|---|---|
tokenAddress | string | The token address |
Type | "ERC20" | The string literal "ERC20" |
TokenAmount
| Name | Type | Description |
|---|---|---|
TokenAmount | ETHToken | ERC721Token | ERC20Token | Union type that represents all token type amounts |
ExchangeTokenAmount
| Name | Type | Description |
|---|---|---|
ExchangeTokenAmount | ETHToken | ERC20Token | Union type that represents exchange token type amounts |
ETHAmount
| Name | Type | Description |
|---|---|---|
Amount | string | An amount in unit Wei |
Type | ETH | Inherited from ETHToken |
ERC20Amount
| Name | Type | Description |
|---|---|---|
Amount | string | An amount in units for the given ERC20 token |
Type | ERC20 | Inherited from ERC20Token |
tokenAddress | string | Inherited from ERC20Token |
FeeEntry
| Name | Type | Description |
|---|---|---|
address | string | (Optional) |
fee_percentage | number |
Request & Response Types
NftTransferDetails
| Name | Type | Description |
|---|---|---|
receiver | string | Ethereum address of the receiving user |
tokenAddress | string | The token contract address |
tokenId | string | The token ID |
CreateTransferResponse
| Name | Type | Description |
|---|---|---|
transfer_ids | number[] | List of transfer IDs |
GetSignableCancelOrderRequest
| Name | Type | Description |
|---|---|---|
order_id | number | ID of the order/offer to be cancelled |
CancelOrderResponse
| Name | Type | Description |
|---|---|---|
order_id | number | ID of the cancelled order / offer |
status | string | New status of the order / offer |
UnsignedOrderRequest
| Name | Type | Description |
|---|---|---|
buy | TokenAmount | For create an order, this is the amount of tokens that will be bought for this order, normally the ERC20 or ETH. For make an offer, This is the amount of tokens that will be bought for this offer, normally the ERC721 |
expiration_timestamp | number | (Optional) ExpirationTimestamp in Unix time. Note: will be rounded down to the nearest hour |
fees | FeeEntry[] | (Optional) Inclusion of either maker or taker fees |
sell | TokenAmount | For create an order, this is the amount of tokens that will be sold for this order, normally the ERC721. For make an offer, This is the amount of tokens that offered for this order, normally the ERC20 or ETH |
CreateOrderResponse
| Name | Type | Description |
|---|---|---|
order_id | number | ID of the created order / offer |
request_id | string | (Optional) Request ID as a reference for an asynchronous order creation request |
status | string | Status of the created order / offer |
time | number | Timestamp of the created order / offer |
GetSignableTradeRequest
| Name | Type | Description |
|---|---|---|
expiration_timestamp | number | (Optional) ExpirationTimestamp in Unix time. Note: will be rounded down to the nearest hour |
fees | FeeEntry[]` | Inclusion of either maker or taker fees |
order_id | number | The ID of the maker order / offer involved |
user | string | Ethereum address of the submitting user |
CreateTradeResponse
| Name | Type | Description |
|---|---|---|
request_id | string | (Optional) Request ID as a reference for an asynchronous trade creation/order acception request |
status | string | Current status of trade(the trade will be created after user accept the offer, this is the current status of trade) |
trade_id | number | ID of trade within Immutable X |
UnsignedExchangeTransferRequest
| Name | Type | Description |
|---|---|---|
| receiver | string | Ethereum address of the receiving user |
| transactionID | string | The transaction ID |
| ExchangeTokenAmount | ExchangeTokenAmount | Union type that represents exchange token type amounts |
UnsignedTransferRequest
| Name | Type | Description |
|---|---|---|
TokenAmount | TokenAmount | Union type that represents all token type amounts |
receiver | string | New status of the order |
CreateTransferResponseV1
| Name | Type | Description |
|---|---|---|
transfer_id | number | ID of the transfer |
time | number | [deprecated] Time of the transfer |
status | string | [deprecated] The status of transfer |
sent_signature | string | [deprecated] Sent signature |
CreateWithdrawalResponse
| Name | Type | Description |
|---|---|---|
tx_hash | string | Immutable signature authorising registration |
RegisterUserResponse
| Name | Type | Description |
|---|---|---|
tx_hash | string | Immutable signature authorising registration |