SDK Overview

iotex-antenna is our SDK allowing you to interact with a local or remote iotex blockchain node, using a gRPC or gRPC-web connection.

Installation

In your JS project root, use npm install or yarn add.

npm install iotex-antenna

In your Golang project root, use go dep or go mod.

go get -u github.com/iotexproject/iotex-antenna-go

Quick Start

Using JS/Golang SDK

  1. generate an account / recover an account from the private key
  2. transfer tokens
  3. run smart contracts
  4. make RPC calls
  5. check the complete API references

Using GraphQL

  1. Documentation
  2. GraphQL Playground

Having questions? Ask in our gitter chat room.

Account

The antenna.iotx.accounts contains functions to generate Iotex accounts and sign transactions and data.

    Transfer

    antenna.iotx.accounts create, sign, and send a transaction of transfer to iotex blockchain network.

      To see the result of the transfer action, you can ether go to https://iotexscan.io/action/:actionHash or query like

        Smart Contract

        The iotx.Contract class makes it easy to interact with smart contracts on the iotex blockchain. When you create a new contract object, you give it the json interface of the respective smart contract, and it will auto converts all calls into low-level ABI calls over RPC for you.

        This allows you to interact with smart contracts as if they were JavaScript objects.

        Compiling Solidity

        iotex-antenna does not compile solidity. However, you can use the following ways to get ABI and bytecode.

        1. option 1: use https://iotexscan.io/wallet/smart-contract/deploy

        2. option 2: in Node.js, use [email protected]

        import solc from "solc";
        
        const solidityFileString = `
        pragma solidity ^0.4.16;
        
        contract SimpleStorage {
           uint storedData;
        
           function set(uint x) public {
               storedData = x;
           }
        
           function get() public view returns (uint) {
               return storedData;
           }
        }
        `;
        const contractName = ":SimpleStorage";
        const output = solc.compile(solidityFileString, 1);
        const abi = JSON.parse(output.contracts[contractName].interface);
        const bytecode = output.contracts[contractName].bytecode;
        
        1. option 3: in browser, use browser-solc. Here is an example from iotex-explorer.

        Deploying Contract

        Once you get the abi and bytecode from the step above, then you can deploy it by sending the execution to the iotex blockchain network.

          Need a full example? Check our integration test.

          Once the action is broadcast, you can query the action.

            Once the action is minted, you can query the receipt.

              Interacting with Smart Contract

              After you get the contract address from the receipt, you can interact with the contract by constructing the contract first, and then calling contract functions.

              There are methods set and get in the example contract SimpleStorage defined in the solidity string above, so you can call them as the following.

                RPC Methods

                The rpc-method(provider) package allows you to make gRPC calls to Iotex blockchain.

                Use the umbrella antenna.iotex package:

                  Use this standalone package: