Skip to content
This repository has been archived by the owner on Nov 29, 2024. It is now read-only.

Latest commit

 

History

History
26 lines (25 loc) · 702 Bytes

automated_token_transfer.md

File metadata and controls

26 lines (25 loc) · 702 Bytes

Automated Token Transfer

Smart Contract transfer function allows for the programmatic/automated transfer of tokens from one application/user via smart contract to the other.

Example

const contract = // .. initialize contract promise here
const appKeyring = // ... initialize
const gasLimitAuto = -1;
const zero = 0;
const transferObj = await contract.tx.transfer(
  zero,
  gasLimitAuto,
  destinationAccountPublicKey,
  amount,
  '',
  '',
);

transferObj
    .signAndSend(appKeyring, ({status}) => {
      if (status.isInBlock) {
        console.log('In block');
      } else if (status.isFinalized) {
        console.log(`Finalized. Hash: ${status.asFinalized.toHex()}`);
      }
})