Skip to main content
Source Link

You should use send instead of call, because token transfer does modify blockchain state:

// transfer 100 tokens form 0xD0A88... to 0x36c90...
contract.transfer.send(
  "0x36C90...", 
  100 * Math.pow (10, 18),
  {
    from: "0xD0A88..."
  }, 
  function(error, txHash) {
    console.log(txHash);
  });

Though, this will not work with Infura, because Infura does not have your private key. You will need to do contract.transfer.getData("0x36C90...", 100 * Math.pow (10, 18)) to get encoded transaction data, and then use this data to construct and sign raw transaction.

BTW, you use floating point arithmetic to calculate number of tokens to be transferred. This way you will loose precision. You should use BigNumber instead.

You should use send instead of call, because token transfer does modify blockchain state:

// transfer 100 tokens form 0xD0A88... to 0x36c90...
contract.transfer.send(
  "0x36C90...", 
  100 * Math.pow (10, 18),
  {
    from: "0xD0A88..."
  }, 
  function(error, txHash) {
    console.log(txHash);
  });

BTW, you use floating point arithmetic to calculate number of tokens to be transferred. This way you will loose precision. You should use BigNumber instead.

You should use send instead of call, because token transfer does modify blockchain state:

// transfer 100 tokens form 0xD0A88... to 0x36c90...
contract.transfer.send(
  "0x36C90...", 
  100 * Math.pow (10, 18),
  {
    from: "0xD0A88..."
  }, 
  function(error, txHash) {
    console.log(txHash);
  });

Though, this will not work with Infura, because Infura does not have your private key. You will need to do contract.transfer.getData("0x36C90...", 100 * Math.pow (10, 18)) to get encoded transaction data, and then use this data to construct and sign raw transaction.

BTW, you use floating point arithmetic to calculate number of tokens to be transferred. This way you will loose precision. You should use BigNumber instead.

added 433 characters in body
Source Link

You should use send instead of call, because token transfer does modify blockchain state:

// transfer 100 tokens form 0xD0A88... to 0x36c90...
contract.transfer.send(
  "0x36C90...", 
  100 * Math.pow (10, 18),
  {
    from: "0xD0A88..."
  }, 
  function(error, txHash) {
    console.log(txHash);
  });

BTW, you use floating point arithmetic to calculate number of tokens to be transferred. This way you will loose precision. You should use BigNumber instead.

You should use send instead of call, because token transfer does modify blockchain state.

You should use send instead of call, because token transfer does modify blockchain state:

// transfer 100 tokens form 0xD0A88... to 0x36c90...
contract.transfer.send(
  "0x36C90...", 
  100 * Math.pow (10, 18),
  {
    from: "0xD0A88..."
  }, 
  function(error, txHash) {
    console.log(txHash);
  });

BTW, you use floating point arithmetic to calculate number of tokens to be transferred. This way you will loose precision. You should use BigNumber instead.

Source Link

You should use send instead of call, because token transfer does modify blockchain state.