Skip to content

Create Token Exchange for ERC-1155 tokens. Prepare Transaction, Retrieve exchange details, refutation timeline and token balances

To create an ERC-1155 token exchange using CMS, prepare its transaction, and then retrieve its exchange details, including the refutation timeline and token balances, follow these steps:

Create an ERC-1155 Token Exchange using CMS:

javascript
import { TradeCms } from "skc-trade-sdk";
const cms = new TradeCms("https://example.com");
const tokenExchange1155 = await cms.createTokenExchange1155(
  "MyTokenExchange1155",
  "offset-value",
  "https://example.com/exchange",
  "0xDepositorAddress",
  "Optional memo"
);

This code initializes the TradeCms instance and creates a new ERC-1155 token exchange.

Prepare the Transaction for the Token Exchange:

javascript
const preparedTokenExchange1155Tx = await cms.prepareTxTokenExchange1155(
  "methodName",
  { arg1: "value1", arg2: "value2" },
  "token-exchange-1155-id",
  "Optional memo"
);

This code prepares the transaction for the specific token exchange operation.

Retrieve the Token Exchange Details:

javascript
const tokenExchange1155Details = await cms.tokenExchange1155Details("exchange-id");

This code fetches the details of the specific ERC-1155 token exchange.

Retrieve the Refutation Timeline:

javascript
import { TokenExchange1155Contract } from 'skc-sdk';
const provider = new ethers.JsonRpcProvider("http://localhost:8545");
const signer = provider.getSigner();
const tokenExchange = new TokenExchange1155Contract("0xYourTokenExchange1155ContractAddress", provider, "http://localhost:8545");
const refutationTimeline = await tokenExchange.refutationsTimeline();

This code initializes the TokenExchange1155Contract instance and retrieves the refutation timeline.

Retrieve the Token Balances:

javascript
const tokens = await tokenExchange.getTokens();

This code fetches the balances for all token ID and address pairs from the event logs.

By following these steps, you can create an ERC-1155 token exchange, prepare its transaction, and retrieve its details, including the refutation timeline and token balances.