본문으로 건너뛰기

Api

EOSIO Javascript / Exports / Api

Class: Api

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new Api(args)

Parameters

NameTypeDescription
argsObject rpc: Issues RPC calls authorityProvider: Get public keys needed to meet authorities in a transaction abiProvider: Supplies ABIs in raw form (binary) signatureProvider: Signs transactions chainId: Identifies chain textEncoder: TextEncoder instance to use. Pass in null if running in a browser * textDecoder: TextDecoder instance to use. Pass in null if running in a browser
args.abiProvider?AbiProvider-
args.authorityProvider?AuthorityProvider-
args.chainId?string-
args.rpcJsonRpc-
args.signatureProviderSignatureProvider-
args.textDecoder?TextDecoder-
args.textEncoder?TextEncoder-

Defined in

src/eosjs-api.ts:64

Properties

abiProvider

abiProvider: AbiProvider

Supplies ABIs in raw form (binary)

Defined in

src/eosjs-api.ts:25


abiTypes

abiTypes: Map<string, Type>

Converts abi files between binary and structured form (abi.abi.json)

Defined in

src/eosjs-api.ts:37


authorityProvider

authorityProvider: AuthorityProvider

Get subset of availableKeys needed to meet authorities in a transaction

Defined in

src/eosjs-api.ts:22


cachedAbis

cachedAbis: Map<string, CachedAbi>

Fetched abis

Defined in

src/eosjs-api.ts:46


chainId

chainId: string

Identifies chain

Defined in

src/eosjs-api.ts:31


contracts

contracts: Map<string, Contract>

Holds information needed to serialize contract actions

Defined in

src/eosjs-api.ts:43


rpc

rpc: JsonRpc

Issues RPC calls

Defined in

src/eosjs-api.ts:19


signatureProvider

signatureProvider: SignatureProvider

Signs transactions

Defined in

src/eosjs-api.ts:28


textDecoder

textDecoder: TextDecoder

Defined in

src/eosjs-api.ts:34


textEncoder

textEncoder: TextEncoder

Defined in

src/eosjs-api.ts:33


transactionTypes

transactionTypes: Map<string, Type>

Converts transactions between binary and structured form (transaction.abi.json)

Defined in

src/eosjs-api.ts:40

Methods

deserialize

deserialize(buffer, type): any

Convert data in buffer to structured form. type must be a built-in abi type or in transaction.abi.json.

Parameters

NameType
bufferSerialBuffer
typestring

Returns

any

Defined in

src/eosjs-api.ts:162


deserializeActions

deserializeActions(actions): Promise<Action[]>

Convert actions from hex

Parameters

NameType
actionsAction[]

Returns

Promise<Action[]>

Defined in

src/eosjs-api.ts:211


deserializeTransaction

deserializeTransaction(transaction): any

Convert a transaction from binary. Leaves actions in hex.

Parameters

NameType
transactionUint8Array

Returns

any

Defined in

src/eosjs-api.ts:195


deserializeTransactionWithActions

deserializeTransactionWithActions(transaction): Promise<any>

Convert a transaction from binary. Also deserializes actions.

Parameters

NameType
transactionstring | Uint8Array

Returns

Promise<any>

Defined in

src/eosjs-api.ts:220


getAbi

getAbi(accountName, reload?): Promise<Abi>

Get abi in structured form. Fetch when needed.

Parameters

NameTypeDefault value
accountNamestringundefined
reloadbooleanfalse

Returns

Promise<Abi>

Defined in

src/eosjs-api.ts:124


getCachedAbi

getCachedAbi(accountName, reload?): Promise<CachedAbi>

Get abi in both binary and structured forms. Fetch when needed.

Parameters

NameTypeDefault value
accountNamestringundefined
reloadbooleanfalse

Returns

Promise<CachedAbi>

Defined in

src/eosjs-api.ts:103


getContract

getContract(accountName, reload?): Promise<Contract>

Get data needed to serialize actions in a contract

Parameters

NameTypeDefault value
accountNamestringundefined
reloadbooleanfalse

Returns

Promise<Contract>

Defined in

src/eosjs-api.ts:141


getTransactionAbis

getTransactionAbis(transaction, reload?): Promise<BinaryAbi[]>

Get abis needed by a transaction

Parameters

NameTypeDefault value
transactionanyundefined
reloadbooleanfalse

Returns

Promise<BinaryAbi[]>

Defined in

src/eosjs-api.ts:129


pushSignedTransaction

pushSignedTransaction(__namedParameters): Promise<any>

Broadcast a signed transaction using push_transaction RPC

Parameters

NameType
__namedParametersPushTransactionArgs

Returns

Promise<any>

Defined in

src/eosjs-api.ts:365


rawAbiToJson

rawAbiToJson(rawAbi): Abi

Decodes an abi as Uint8Array into json.

Parameters

NameType
rawAbiUint8Array

Returns

Abi

Defined in

src/eosjs-api.ts:89


sendSignedTransaction

sendSignedTransaction(__namedParameters): Promise<any>

Broadcast a signed transaction using send_transaction RPC

Parameters

NameType
__namedParametersPushTransactionArgs

Returns

Promise<any>

Defined in

src/eosjs-api.ts:376


sendSignedTransaction2

sendSignedTransaction2(__namedParameters): Promise<any>

Broadcast a signed transaction using send_transaction2 RPC

Parameters

NameType
__namedParametersSendTransaction2Args

Returns

Promise<any>

Defined in

src/eosjs-api.ts:387


serialize

serialize(buffer, type, value): void

Convert value to binary form. type must be a built-in abi type or in transaction.abi.json.

Parameters

NameType
bufferSerialBuffer
typestring
valueany

Returns

void

Defined in

src/eosjs-api.ts:157


serializeActions

serializeActions(actions): Promise<SerializedAction[]>

Convert actions to hex

Parameters

NameType
actionsAction[]

Returns

Promise<SerializedAction[]>

Defined in

src/eosjs-api.ts:202


serializeContextFreeData

serializeContextFreeData(contextFreeData): Uint8Array

Serialize context-free data

Parameters

NameType
contextFreeDataUint8Array[]

Returns

Uint8Array

Defined in

src/eosjs-api.ts:182


serializeTransaction

serializeTransaction(transaction): Uint8Array

Convert a transaction to binary

Parameters

NameType
transactionany

Returns

Uint8Array

Defined in

src/eosjs-api.ts:167


transact

transact(transaction, __namedParameters?): Promise<any>

Create and optionally broadcast a transaction.

Named Parameters:

  • broadcast: broadcast this transaction?
  • sign: sign this transaction?
  • useOldRPC: use old RPC push_transaction, rather than new RPC send_transaction?
  • useOldSendRPC: use old RPC /v1/chain/send_transaction, rather than new RPC /v1/chain/send_transaction2?
  • returnFailureTrace: return partial traces on failed transactions?
  • retryTrxNumBlocks: request node to retry transaction until in a block of given height, blocking call?
  • retryIrreversible: request node to retry transaction until it is irreversible or expires, blocking call?
  • If both blocksBehind and expireSeconds are present, then fetch the block which is blocksBehind behind head block, use it as a reference for TAPoS, and expire the transaction expireSeconds after that block's time.

Parameters

NameType
transactionany
__namedParametersObject
__namedParameters.blocksBehind?number
__namedParameters.broadcast?boolean
__namedParameters.expireSeconds?number
__namedParameters.retryIrreversible?boolean
__namedParameters.retryTrxNumBlocks?number
__namedParameters.returnFailureTrace?boolean
__namedParameters.sign?boolean
__namedParameters.useOldRPC?boolean
__namedParameters.useOldSendRPC?boolean

Returns

Promise<any>

node response if broadcast, {signatures, serializedTransaction} if !broadcast

Defined in

src/eosjs-api.ts:248