Start Transaction (Token)

Start Transaction (Token)

To start a transaction with a token (ERC20 or ERC1155), the user must first make a transaction to authorize the Escrow smart contract to spend a certain amount of their tokens.

In this example we have the following information :

  • Marketplace id : marketplaceId1

  • Ad id : adId1

  • Price of the ad (excluding fees) : 1 token

  • Seller's address : 0x70997970C51812dc3A010C7d01b50e0d17dc79C8

The fee for this token is 1%, the user must first make a transaction to authorize the smart contact to spend the total amount (price+fees) :1,01

//Approve the escrow contract
await token.approve(escrow.address, ethers.utils.parseEther("1.01"));

//New transaction
await escrow.startTransaction(
    "marketplaceId1", //Marketplace id
    "adId1", //Ad id
    ethers.utils.parseEther("1"), //ad price
    token.address, //Token address
    "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" //Seller's address
);

Last updated