Appearance
Prepare Transaction for Token Exchange with ERC-1155 tokens
To prepare a transaction for an ERC-1155 token exchange, you can use the prepareTxTokenExchange1155
method from the TradeCms
class in the skc-trade-sdk
.
Prepare Transaction using CMS
This method is specifically designed for preparing transactions related to ERC-1155 token exchanges. Here is an example of how to use it:
javascript
import { TradeCms } from "skc-trade-sdk";
const cms = new TradeCms("https://example.com");
const preparedTokenExchange1155Tx = await cms.prepareTxTokenExchange1155(
"methodName",
{ arg1: "value1", arg2: "value2" },
"token-exchange-1155-id",
"Optional memo"
);
This method requires the following parameters:
methodName
: The name of the method to call on the contract.args
: The arguments to pass to the method.tokenExchange1155Id
: The identifier of the token exchange.memo
(optional): An optional memo to attach to the transaction.
Prepare Transaction using TokenExchange1155Contract
Alternatively, if you are using the TokenExchange1155Contract
class from the skc-sdk
, you can prepare the transaction data using the prepareTxData
method. Here is an example:
javascript
import { TokenExchange1155Contract } from 'skc-sdk';
const provider = new ethers.JsonRpcProvider("http://localhost:8545");
const signer = provider.getSigner();
const tokenExchange = new TokenExchange1155Contract("0xYourTokenExchange1155ContractAddress", signer, "http://localhost:8545");
const txData = await tokenExchange.prepareTxData(
"createExchange",
["0xUserAddress", "TokenAddress", 1000],
"0xSignerAddress",
"Creating exchange"
);
This method requires the following parameters:
methodName
: The name of the method to call on the contract.args
: The arguments to pass to the method.signerAddress
: The address of the signer initiating the transaction.memo
(optional): An optional memo to attach to the transaction.