Make IOTX Transfers

The object antenna.iotx contains functions to create, sign, and send actions to the IoTeX blockchain.

import Antenna from "iotex-antenna";
import { toRau } from "iotex-antenna/lib/account/utils";

(async () => {
  const antenna = new Antenna("https://api.testnet.iotex.one");
  const unlockedWallet = await antenna.iotx.accounts.privateKeyToAccount(
    "73c7b4a62bf165dccf8ebdea8278db811efd5b8638e2ed9683d2d94889450426"
  );
  const newWallet = antenna.iotx.accounts.create("any entropy");

  const actionHash = await antenna.iotx.sendTransfer({
    from: unlockedWallet.address,
    to: newWallet.address,
    value: toRau("1", "iotx"),
    gasLimit: "100000",
    gasPrice: toRau("1", "Qev")
  });
})();

To see the result of the transfer action, you can either go to the iotex explorer or query the blockchain using antenna sdk like:

const action = await antenna.iotx.getActions({
  byHash: {
    actionHash:
      "91524e81da32c2ad75af76c673b2e01920e69a95737a4a5438e6d0da6b910616",
    checkingPending: true
  }
});

Last updated

Logo

This documentation portal is currently undergoing updates to align with the IoTeX 2.0 Whitepaper release. Information provided here may be incomplete, or out-of-date. Please use this portal for preliminary reference only, and check out the official IoTeX 2.0 Whitepaper for updated information.

.

2024 | IoTeX