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 Methods

  • batchNftTransfer

  • cancelOrder

  • completeWithdrawal

  • createOrder

  • createTrade

  • deposit

  • exchangeTransfer

  • getAddress

  • isRegisteredOnchain

  • prepareWithdrawal

  • 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

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

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>

Create an Order

Parameters

Name
Type
Description

request

UnsignedOrderRequest

The unsigned order request to create an order

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

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


registerOffchain

registerOffchain(): Promise<RegisterUserResponse>

Register a User to XpansionChain 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 to be cancelled


CancelOrderResponse

Name
Type
Description

order_id

number[]

ID of the cancelled order

status

string

New status of the order


UnsignedOrderRequest

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


CreateOrderResponse

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


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 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 request

status

string

Current status of trade

trade_id

number

ID of trade within XpansionChain


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

XpansionChain signature authorising registration


RegisterUserResponse

Name
Type
Description

tx_hash

string

XpansionChain signature authorising registration

Last updated