chain

chain

Methods

(static) abiBin2json(code, action, binargs)

Convert bin hex back into Abi json definition.

Example
import {abiBin2json} from "u3.js/src";
const u3 = createU3(config);
await u3.abiBin2json({
  "code": "account1",
  "action": "account2",
  "binargs": "000000008093dd74000000000094dd74e803000000000000"
});
Parameters:
Name Type Description
code name

Provide the smart contract account name

action name

Provide the action name

binargs bytes

Provide the binary arguments

(static) abiJson2bin(code, action, args)

Manually serialize json into binary hex. The binayargs is usually stored in Action.data.

Example
import {abiJson2bin} from "u3.js/src";
const u3 = createU3(config);
await u3.abiJson2bin({
  "code": "account1",
  "action": "account2",
  "args": {
    "from": "initb",
    "to": "initc",
    "quantity": 1000
  }
});
Parameters:
Name Type Description
code name

Provide the account name.

action name

Provide the action arguments

args bytes

Provide the json arguments

(static) createUser(creator, name, owner, active, updateablenullable)

create an account

Example
import {createUser} from "u3.js/src";
const u3 = createU3(config);
await u3.createUser({
  "creator": "ben",
  "name": "abcdefg12345",
  "owner": "UTR1uHKWW5tvmw6eQpbv92cVmkpDFhQ9q7xsee5Da2X2pVeYUNy4D",
  "active": "UTR1uHKWW5tvmw6eQpbv92cVmkpDFhQ9q7xsee5Da2X2pVeYUNy4D",
  "updateable": 1
});
Parameters:
Name Type Attributes Description
creator account_name

account of creator

name account_name

account to be created

owner string

owner public key to be bind

active string

active public key to be bind

updateable uint32 <nullable>

whether the account can be updated

(static) deploy(contract, account)

deploy a contract to ultrain

Example
import {deploy} from "u3.js/src";
const u3 = createU3(config);
await u3.deploy({
  "contract": "/Users/benyasin/demo/contracts/token/token",
  "account": "ben"
});
Parameters:
Name Type Description
contract string

contract file path

account account_name

contract owner account

(static) getAbi(account_name)

Example
import {getAbi} from "u3.js/src";
const u3 = createU3(config);
await u3.getAbi({
  "account_name": "account"
});
Parameters:
Name Type Description
account_name name

name of account to retrieve ABI for

(static) getAccountInfo(account_name)

Fetch a blockchain account

Example
import {getAccountInfo} from "u3.js/src";
const u3 = createU3(config);
await u3.getAccountInfo({
  "account_name": "account"
});
Parameters:
Name Type Description
account_name name

Provide an account name

(static) getBlockHeaderState(block_num_or_id)

Fetch the minimum state necessary to validate transaction headers.

Example
import {getBlockHeaderState} from "u3.js/src";
const u3 = createU3(config);
await u3.getBlockHeaderState({
  "block_id": "0000000280155952392ddaa5c4fb6611e74e3c93f61852c50f67f47c9c8b90ba"
});
Parameters:
Name Type Description
block_num_or_id string

Provide a block number or a block id

(static) getBlockInfo(block_num_or_id)

Fetch a block from the blockchain.

Example
import {getBlockInfo} from "u3.js/src";
const u3 = createU3(config);
await u3.getBlockInfo({
  "block_id": "0000000280155952392ddaa5c4fb6611e74e3c93f61852c50f67f47c9c8b90ba"
});
Parameters:
Name Type Description
block_num_or_id string

Provide a block number or a block id

(static) getChainInfo()

Return general network information.

(static) getContract(account_name, code_as_wasm)

Fetch smart contract code

Example
import {getContract} from "u3.js/src";
const u3 = createU3(config);
await u3.getContract({
  "account_name": "account"
});
Parameters:
Name Type Description
account_name name

Provide a smart contract account name

code_as_wasm bool

was deprecated

(static) getCurrencyBalance(code, account, symbol)

Example
import {getCurrencyBalance} from "u3.js/src";
const u3 = createU3(config);
await u3.getCurrencyBalance({
  "code": "account",
  "account": "account",
  "symbol": "UGAS"
});
Parameters:
Name Type Description
code name

account which deployed the contract

account name

account to get balance of

symbol optional.<string>

symbol to query

(static) getCurrencyStats(code, symbol)

Example
import {getCurrencyStats} from "u3.js/src";
const u3 = createU3(config);
await u3.getCurrencyStats({
  "code": "account",
  "symbol": "UGAS"
});
Parameters:
Name Type Description
code name

account which deployed the contract

symbol string

currency symbol to get the stats for

(static) getProducerInfo(owner)

Return producer info

Parameters:
Name Type Description
owner account_name

account of producer

(static) getRawCodeAndAbi(account_name)

Example
import {getRawCodeAndAbi} from "u3.js/src";
const u3 = createU3(config);
await u3.getRawCodeAndAbi({
  "account_name": "account"
});
Parameters:
Name Type Description
account_name name

Account name to get code and abi for

(static) getRequiredKeys(transaction, available_keys)

Example
import {getRequiredKeys} from "u3.js/src";
const u3 = createU3(config);
await u3.getRequiredKeys({
  "transaction": {
    "ref_block_num": "100",
    "ref_block_prefix": "137469861",
    "expiration": "2017-09-25T06:28:49",
    "scope": [
      "initb",
      "initc"
    ],
    "actions": [
      {
        "code": "currency",
        "type": "transfer",
        "recipients": [
          "initb",
          "initc"
        ],
        "authorization": [
          {
            "account": "initb",
            "permission": "active"
          }
        ],
        "data": "000000000041934b000000008041934be803000000000000"
      }
    ],
    "signatures": [],
    "authorizations": []
  },
  "available_keys": [
    "EOS4toFS3YXEQCkuuw1aqDLrtHim86Gz9u3hBdcBw5KNPZcursVHq",
    "EOS7d9A3uLe6As66jzN8j44TXJUqJSK3bFjjEEqR4oTvNAB3iM9SA",
    "EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV"
  ]
});
Parameters:
Name Type Description
transaction transaction

Provide the transaction object

available_keys Array

Provide the available keys

(static) getScheduledTransactions(json, lower_bound, limit)

Example
import {getScheduledTransactions} from "u3.js/src";
const u3 = createU3(config);
await u3.getScheduledTransactions({
  "json": false,
  "lower_bound": "2a57d0f636625abc9f63656e3b8ada8b8b7a4fdf7a7663e4db27bc88be730b51",
  "limit": "50"
});
Parameters:
Name Type Description
json bool

Provide true or false

lower_bound string

timestamp OR transaction ID

limit uint32

(static) getTableByScope(code, table, lower_bound, upper_bound, limit)

Fetch smart contract data from an account.

Example
import {getTableByScope} from "u3.js/src";
const u3 = createU3(config);
await u3.getTableByScope({
  "code": "account1",
  "table": "table",
  "lower_bound": "0",
  "upper_bound": "-1",
  "limit": "10"
});
Parameters:
Name Type Description
code name

Provide the smart contract name

table name

Provide the table name

lower_bound string
upper_bound string
limit uint32

(static) getTableRecords(json, code, scope, table, table_key, lower_bound, upper_bound, limit, key_type, index_position)

Fetch smart contract data from an account.

Example
import {getTableRecords} from "u3.js/src";
const u3 = createU3(config);
await u3.getTableRecords({
  "json": false,
  "code": "account1",
  "scope": "account2",
  "table": "table",
  "table_key": "",
  "lower_bound": "0",
  "upper_bound": "-1",
  "limit": "10",
  "key_type": "i64",
  "index_position": ""
});
Parameters:
Name Type Description
json bool

Provide true or false

code name

Provide the smart contract name

scope string

Provide the account name

table name

Provide the table name

table_key string

-

lower_bound string
upper_bound string
limit uint32
key_type string

The key type of --index,
primary only supports (i64),
all others support (i64, i128, i256, float64, float128).
Special type 'name' indicates an account name.

index_position string

1 - primary (first),
2 - secondary index (in order defined by multi_index),
3 - third index, etc

(static) pushBlock(block)

Append a block to the chain database.

Parameters:
Name Type Description
block signed_block

-

(static) pushTx(signed_transaction)

Attempts to push the transaction into the pending queue.

Parameters:
Name Type Description
signed_transaction signed_transaction

Provide the authorizations for the transaction

(static) pushTxs(signed_transaction[)

Attempts to push transactions into the pending queue.

Parameters:
Name Type Description
signed_transaction[ signed_transaction

Provide the authorizations for the transaction

(static) queryResource(name)

Return resource detail of an account

Example
import {queryResource} from "u3.js/src";
const u3 = createU3(config);
await u3.queryResource({
  "name": "du3kwow2bkay"
});
Parameters:
Name Type Description
name account_name

account to query

(static) registerEvent(account, post_url)

subscribe to ultrain chain event.

Example
import {registerEvent} from "u3.js/src";
const u3 = createU3(config);
await u3.registerEvent({
  "account": "name",
  "post_url": "http://10.10.10.114:3002"
});
Parameters:
Name Type Description
account name

Provide the action name

post_url string

-

(static) sign(unsigned_transaction, privateKeyOrMnemonic, chainId)

sign an unsigned transaction offline and in a separate

Example
import {sign} from "u3.js/src";
const u3_offline = createU3({ sign: false, broadcast: false });
const unsigned_transaction = await u3_offline.anyAction('args', {keyProvider});
let signature = await u3_offline.sign(unsigned_transaction, '5KWW3MQbqibqmC...','baf8bb9d3636...');
Parameters:
Name Type Description
unsigned_transaction object

an unsigned transaction returned when an action called by a offline u3 instance

privateKeyOrMnemonic string

private key or mnemonic

chainId string

chainId

(static) unregisterEvent(account, post_url)

unsubscribe to ultrain chain event.

Example
import {unregisterEvent} from "u3.js/src";
const u3 = createU3(config);
await u3.unregisterEvent({
  "account": "name",
  "post_url": "http://10.10.10.114:3002"
});
Parameters:
Name Type Description
account name

Provide the action name

post_url string

-