IMX Provider

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 XpansionChain StarkEx network, XpansionChain 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 Methodsarrow-up-right

  • batchNftTransfer

  • cancelOrder

  • completeWithdrawal

  • createOrder

  • createTrade

  • deposit

  • exchangeTransfer

  • getAddress

  • isRegisteredOnchain

  • prepareWithdrawal

  • registerOffchain

  • transfer

Method Detailsarrow-up-right

batchNftTransferarrow-up-right

batchNftTransfer(request): Promise<CreateTransferResponse>

Create a batch of NFT transfer requests

Parametersarrow-up-right

Name
Type
Description

request

NftTransferDetails[]

An array of NFT transfer details

Returnsarrow-up-right

Promise<CreateTransferResponse>

Resolves a promise that resolves with the list of Transfer IDs

Defined inarrow-up-right

src/modules/provider/imxProvider.ts:73


cancelOrder(request): Promise<CancelOrderResponse>

Cancel an Order

Parametersarrow-up-right

Name
Type
Description

request

GetSignableCancelOrderRequest

The signable cancel order request

Returnsarrow-up-right

Promise<CancelOrderResponse>

Returns a promise that resolves with the cancelled Order

Defined inarrow-up-right

src/modules/provider/imxProvider.ts:52


completeWithdrawalarrow-up-right

completeWithdrawal(starkPublicKey, token): Promise<TransactionResponse>

Completes a Withdrawal

Parametersarrow-up-right

Name
Type
Description

starkPublicKey

string

The stark public key

token

AnyToken

The token to withdraw

Returnsarrow-up-right

Promise<TransactionResponse>

Returns a promise that resolves with the transaction

Defined inarrow-up-right

src/modules/provider/imxProvider.ts:102


createOrder(request): Promise<CreateOrderResponse>

Create an Order

Parametersarrow-up-right

Name
Type
Description

request

UnsignedOrderRequest

The unsigned order request to create an order

Returnsarrow-up-right

Promise<CreateOrderResponse>

Returns a promise that resolves with the created Order

Defined inarrow-up-right

src/modules/provider/imxProvider.ts:45


createTrade(request): Promise<CreateTradeResponse>

Create a Trade

Parametersarrow-up-right

Name
Type
Description

request

GetSignableTradeRequest

The signable trade request

Returnsarrow-up-right

Promise<CreateTradeResponse>

Returns a promise that resolves with the created Trade

Defined inarrow-up-right

src/modules/provider/imxProvider.ts:59


deposit(deposit): Promise<TransactionResponse>

Deposit either ETH, ERC20 or ERC721 tokens

Parametersarrow-up-right

Name
Type

deposit

TokenAmount

Returnsarrow-up-right

Promise<TransactionResponse>

Returns a promise that resolves with the transaction

Defined inarrow-up-right

src/modules/provider/imxProvider.ts:87


exchangeTransferarrow-up-right

exchangeTransfer(request): Promise<CreateTransferResponseV1>

Create a new Exchange transaction

Parametersarrow-up-right

Name
Type
Description

request

UnsignedExchangeTransferRequest

The unsigned exchange transfer request

Returnsarrow-up-right

Promise<CreateTransferResponseV1>

Returns a promise that resolves with the created Exchange Transaction

Defined inarrow-up-right

src/modules/provider/imxProvider.ts:80


getAddress(): Promise<string>

Get the Signer address

Returnsarrow-up-right

Promise<string>

Returns a promise that resolves with the signer's address

Defined inarrow-up-right

src/modules/provider/imxProvider.ts:26


isRegisteredOnchainarrow-up-right

isRegisteredOnchain(): Promise<boolean>

Checks if a User is registered on-chain

Returnsarrow-up-right

Promise<boolean>

Returns a promise that resolves with true if the User is registered, false otherwise

Defined inarrow-up-right

src/modules/provider/imxProvider.ts:38


prepareWithdrawalarrow-up-right

prepareWithdrawal(request): Promise<CreateWithdrawalResponse>

Create a Withdrawal

Parametersarrow-up-right

Name
Type
Description

request

TokenAmount

The token type amount in its corresponding unit

Returnsarrow-up-right

Promise<CreateWithdrawalResponse>

Returns a promise that resolves with the created Withdrawal

Defined inarrow-up-right

src/modules/provider/imxProvider.ts:94


registerOffchainarrow-up-right

registerOffchain(): Promise<RegisterUserResponse>

Register a User to XpansionChain if they are not already registered

Returnsarrow-up-right

Promise<RegisterUserResponse>

Returns a promise that resolves with the user registration response

Defined inarrow-up-right

src/modules/provider/imxProvider.ts:32


transfer(request): Promise<CreateTransferResponseV1>

Create a new Transfer request

Parametersarrow-up-right

Name
Type
Description

request

UnsignedTransferRequest

The unsigned transfer request

Returnsarrow-up-right

Promise<CreateTransferResponseV1>

Returns a promise that resolves with the created Transfer

Defined inarrow-up-right

src/modules/provider/imxProvider.ts:66


Name
Type
Description

token

ETHToken | ERC721Token | ERC20Token

ID of the cancelled order

An ETH token

Name
Type
Description

Type

"ETH"

The string literal "ETH"

An ERC721 token

Name
Type
Description

tokenAddress

string

The token address

tokenId

string

The token ID

type

"ERC721"

The string literal "ERC721"

An ERC20 token

Name
Type
Description

tokenAddress

string

The token address

Type

"ERC20"

The string literal "ERC20"

Name
Type
Description

TokenAmount

ETHToken | ERC721Token | ERC20Token

Union type that represents all token type amounts

ExchangeTokenAmountarrow-up-right

Name
Type
Description

ExchangeTokenAmount

ETHToken | ERC20Token

Union type that represents exchange token type amounts

Name
Type
Description

Amount

string

An amount in unit Wei

Type

ETH

Inherited from ETHToken

Name
Type
Description

Amount

string

An amount in units for the given ERC20 token

Type

ERC20

Inherited from ERC20Token

tokenAddress

string

Inherited from ERC20Token

Name
Type
Description

address

string

(Optional)

fee_percentage

number

Request & Response Typesarrow-up-right

NftTransferDetailsarrow-up-right

Name
Type
Description

receiver

string

Ethereum address of the receiving user

tokenAddress

string

The token contract address

tokenId

string

The token ID

CreateTransferResponsearrow-up-right

Name
Type
Description

transfer_ids

number[]

List of transfer IDs


GetSignableCancelOrderRequestarrow-up-right

Name
Type
Description

order_id

number[]

ID of the order to be cancelled


CancelOrderResponsearrow-up-right

Name
Type
Description

order_id

number[]

ID of the cancelled order

status

string

New status of the order


UnsignedOrderRequestarrow-up-right

Name
Type
Description

buy

TokenAmount

The amount of tokens that will be bought for this order

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

The amount of tokens that will be sold for this order


CreateOrderResponsearrow-up-right

Name
Type
Description

order_id

number

ID of the created order

request_id

string

(Optional) Request ID as a reference for an asynchronous order creation request

status

string

Status of the created order

time

number

Timestamp of the created order


GetSignableTradeRequestarrow-up-right

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 involved

user

string

Ethereum address of the submitting user


CreateTradeResponsearrow-up-right

Name
Type
Description

request_id

string

(Optional) Request ID as a reference for an asynchronous trade creation request

status

string

Current status of trade

trade_id

number

ID of trade within XpansionChain


UnsignedExchangeTransferRequestarrow-up-right

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


UnsignedTransferRequestarrow-up-right

Name
Type
Description

TokenAmount

TokenAmount

Union type that represents all token type amounts

receiver

string

New status of the order


CreateTransferResponseV1arrow-up-right

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


CreateWithdrawalResponsearrow-up-right

Name
Type
Description

tx_hash

string

XpansionChain signature authorising registration


RegisterUserResponsearrow-up-right

Name
Type
Description

tx_hash

string

XpansionChain signature authorising registration

Last updated