Trade Requests
Learn more about how to set-up trading in your integration project.
Trading requests are possible with the Enjin API, with trading requests, you are able to interact with players through a project > player trade or player > player trade within your project, allowing you to set up an exchange environment within your own project.
Using trade requests, both Enjin Coin (ENJ) and ERC-1155 assets created using the Enjin Platform can be traded.
Mutations:
The Enjin Trade has 2 mutations:
Mutation
Usage
CreateTrade
Used to initiate the trade request.
CompleteTrade
Used to complete the trade request based on parameters from the CreateTrade request.

CreateTrade

The CreateTrade mutation allows you to trade assets (FTs or NFTs) and trade assets for ENJ as well.
mutation {
CreateTrade(
askingAssets: [{ assetId: "XXXXXXXXXXX", value: 1 }],
offeringAssets: [{ assetId: "XXXXXXXXXXX", value: 1, assetIndex:"XXXXXXXXXXX"}],
secondParty: "WalletAddress"
wallet: "WalletAddress"
)
{
transactionId
id
state
value
asset{name id}
user{name}
}
}
Note that the walletparameter is the initiator, while the secondParty is the person who's interacting with the trade.
After approving the request through the wallet, you may want to query the status of this specific transaction with the GetTransactionquery as you will need to have the id for the transaction in order to complete the trade.

CompleteTrade

Use this mutation to complete the trade request initiated by the previous mutation.
mutation {
CompleteTrade(
tradeId: "XXXXXX",
wallet: "WalletAddress"
)
{
transactionId
id
state
value
asset{name id}
user{name}
}
}
Export as PDF
Copy link