0
votes

Actually from our backend we are sending 2 transactions to the Ethereum Blockchain, first Tx we sent tokens, and second Tx we send Data as names, age, passport etc.

can we send everything in only 1 Transaction? Data and Tokens ?

Thanks for your help

1

1 Answers

1
votes

Yes. You can send ETH with any smart contract transaction call.

If you are wanting to send some token other than ETH in one transaction, write a contract that handles this logic

contract OneTx {
  mapping(address => string) names;

  function constructor() {
    ERC20 erc20 = ERC20("0x...")
  }

  function doStuff(address from, address to, uint amount, string name) {
    erc20.transferFrom(from, to, amount);
    names[from] = name;
  }
}

Keep in mind you need the contract to be approved to move funds on behalf of from