| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [View Raw Code] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
Classes for managing accounts and account-related actions.
export interface TxReceipt {
success: boolean;
cumulative_gas: number;
}
interface TxParams {
version: number;
toAddr: string;
amount: BN;
gasPrice: BN;
gasLimit: Long;
code?: string;
data?: string;
receipt?: TxReceipt;
nonce?: number;
pubKey?: string;
signature?: string;
}When you give nonce, you should give pubKey together.
Class for managing an account (i.e., a private/public keypair).
Parameters
Returns
Generates an account from any JSON-encoded string that complies with the Web3 Secret Storage definition.
Parameters
Returns
Encrypts and JSON-encodes the account. Complies with the Web3 Secret Storage definition.
Parameters
Returns
Signs arbitrary bytes (most often transactions) using a Schnorr signing scheme.
Parameters
Returns
Class for managing multiple accounts.
Parameters
Returns
An object consisting of address: Account KV pairs. By default, an empty object.
The default account used for signing transactions. By default, undefined. It is set to the 0-indexed account when a Wallet instance is constructed.
Creates a new keypair with a randomly-generated private key. The new account is accessible by address. This method mutates the Wallet instance.
Parameters
None
Returns
Adds an Account to the Wallet.
Parameters
Returns
Adds an account by keystore. This method is asynchronous and returns a Promise<string>, in order not to block on the underlying decryption operation.
Parameters
Returns
Adds an Account by use of a mnemonic as specified in BIP-32 and BIP-39
Parameters
Returns
Parameters
Returns
Parameters
Returns
Sets the default account to sign with.
Parameters
Returns
Sign a Transaction with the default Account. This method is asynchronous as it will attempt to obtain the nonce from the Provider. There is an offline mode that can be activated manually by setting the optional offlineSign parameter.
Parameters
Note: In offline mode, the nonce must be explicitly set in the Transaction object.
See examples/node/walletSign.js for demonstration.
Returns
Sign a Transaction with the chosen Account. This method is asynchronous as it will attempt to obtain the nonce from the Provider. There is an offline mode that can be activated manually by setting the optional offlineSign parameter.
Parameters
Note: In offline mode, the nonce must be explicitly set in the Transaction object.
Returns
A class that represents a single Transaction on the Zilliqa network. It is a functor. Its purpose is to encode the possible states a Transaction can be in: Confirmed, Rejected, Pending, or Initialised (i.e., not broadcasted).
A getter protobuf that returns a Buffer of protobuf-encoded bytes. This is a convenience member that allows a Transaction to be signed easily.
A getter than computes the address of the Transaction sender. If there is no sender public key set, returns 0x00000000000000000000000000000000000000000000.
A getter that returns the current TxParams.
Instantiates a Transaction in Confirmed state.
Parameters
Returns
Example
import { HTTPProvider } from '@zilliqa-js/core';
import { Transaction } from '@zilliqa-js/account';
const txParams = {
version: 0,
toAddr: '20_byte_hex_string',
amount: new BN(8),
gasPrice: new BN(100),
gasLimit: Long.fromNumber(888)
};
const tx = Transaction.confirm(txParams, new HTTPProvider('http://my-api.com'));
expect(tx.isConfirmed()).toBeTruthy();Instantiates a Transaction in Rejected state.
Parameters
Returns
Example
import { HTTPProvider } from '@zilliqa-js/core';
import { Transaction } from '@zilliqa-js/account';
const txParams = {
version: 0,
toAddr: '20_byte_hex_string',
amount: new BN(8),
gasPrice: new BN(100),
gasLimit: Long.fromNumber(888),
};
const tx = Transaction.reject(txParams, new HTTPProvider('http://my-api.com'));
expect(tx.isRejected()).toBeTruthy();Checks whether the Transaction is confirmed on the blockchain, by verifying the its receipt status (boolean). This method uses an exponential backoff to poll the lookup node. By default, the number of attempts made is 33, with a starting interval of 1000ms.
Parameters
Returns
Example
import { HTTPProvider } from '@zilliqa-js/core';
import { Transaction } from '@zilliqa-js/account';
// hash can be obtained from CreateTransaction
const my_hash = 'some_known_tx_hash';
conts tx = new Transaction(params, new HTTPProvider('http://my-api.com'));
tx.confirm(some_hash)
.map((tx) => // do something)
.catch((err) => // handle the error);Checks whether the Transaction is confirmed on the blockchain, by verifying the its receipt status (boolean). This method uses latest blockNumber to get the transaction receipt, which is more frendily to remote lookup node. By default, the number of blockCount is 4, with a starting interval of 1000ms. The member Transaction.blockConfirmation will count the block numbers during the process.
Parameters
Returns
Example
import { HTTPProvider } from '@zilliqa-js/core';
import { Transaction } from '@zilliqa-js/account';
// hash can be obtained from CreateTransaction
const my_hash = 'some_known_tx_hash';
conts tx = new Transaction(params, new HTTPProvider('http://my-api.com'));
tx.blockConfirm(some_hash)
.map((tx) => // do something)
.catch((err) => // handle the error);Maps over the transaction, taking a callback that accepts TxParams. The user may freely mutate the Transaction, and will receive the newly-mutated transaction. The object returned is merged into the target Transaction.
Parameters
Returns
Example
import { HTTPProvider } from '@zilliqa-js/core';
import { Transaction } from '@zilliqa-js/account';
// hash can be obtained from CreateTransaction
const my_hash = 'some_known_tx_hash';
let tx = new Transaction(params, new HTTPProvider('http://my-api.com'));
async () => {
try {
tx = await tx.confirm(some_hash);
if (tx.isConfirmed()) {
.map((tx) => {
// do something, but must always return `TxParams`.
// generally, you should avoid performing side effects in `map`.
return tx
});
}
} catch (err) {
// handle this error somehow
}
}();Encodes a transaction with protobuf and returns its bytes as a Buffer. Used for providing a payload to signTransaction.
Parameters
Returns
| Back | FazBrowse Home | New Git URL |