Catalog npm
Back to packageRELEASE DETAILS

2.1.0

npm

@0xbigboss/pocketjs-transaction-builder

Transaction manager and utilties for the Pocket Network protocol

Published2 Oct 2022
Direct dependencies21
Transitive dependenciesNot calculated

README

Current package documentation

TransactionBuilder

This package houses the TransactionBuilder, which lets you build a transaction to then send into the network.

Installation

Install through your package manager of choice:

pnpm install @pokt-foundation/pocketjs-transaction-builder

Usage

import { TransactionBuilder } from '@pokt-foundation/pocketjs-transaction-builder'

// Initializing the TransactionBuilder is simple:
// 1. Instanciate a provider
export const provider = new JsonRpcProvider({
  rpcUrl: MAINNET_RPC_URL,
})

// 2. Instanciate a signer
export const signer = await KeyManager.fromPrivateKey(process.env.PRIVATE_KEY)

// 3. Instanciate the TransactionBuilder
export const builder = new TransactionBuilder({
  signer,
  provider,
});

// Create a new `Send` Message which is used to send funds over the network.
const sendMsg = transactionBuilder.send(
  signer.getAddress(), 
  "07a6fca4dea9f01e4c19f301df0d0afac128561b",
  // Amount in uPOKT (1 POKT = 1*10^6 uPOKT)
  "1000000"
)
// Send it over the network!
const txresponse = await transactionBuilder.submit({
  memo: "POKT Payment",
  txMsg: sendMsg,
})

TransactionBuilder API

Constructor

signer

  • type: KeyManager The KeyManager instance that holds the staked app in the blockchain.

provider

  • type: JsonRpcProvider | IsomorphicProvider The provider instance with available dispatchers to talk to the network.

chainID (optional)

  • type: mainnet | localnet | testnet ChainID to send the transactions to. The provider endpoint must be connected to that chain ID.

Methods

getChainID(): ChainID

Gets the current chain ID this transaction builder has been initialized for.

Returns ChainID: 'mainnet', 'localnet', or 'testnet'.

setChainID(id): void

Sets the chainID to one of the supported networks.

ParamTypeDescription
idstringThe chain to send transactions to. The provider must be connected to that chain

createTransaction({ fee, memo, txMsg }): Promise

Signs and creates a transaction object that can be submitted to the network given the parameters and called upon Msgs.

Returns Promise<RawTxRequest>: The raw transaction request which can be sent over the network.

ParamTypeDescription
feestringThe amount to pay as a fee for executing this transaction, in uPOKT (1 POKT = 1*10^6 uPOKT)
memostringMemo field for this transaction.
txMsgTxMsgTransaction message generated with one of the available methods.

submit({ fee, memo, txMsg }): Promise

Submit receives a valid transaction message, creates a Raw Transaction Request and sends it over the network.

Returns Promise<TransactionResponse: The transaction response from the network, containing the transaction hash.

ParamTypeDescription
feestringThe amount to pay as a fee for executing this transaction, in uPOKT (1 POKT = 1*10^6 uPOKT)
memostringMemo field for this transaction.
txMsgTxMsgTransaction message generated with one of the available methods.

submitRawTransaction(tx): Promise

Submit receives an already made Raw Transaction Request and sends it over the network.

Returns Promise<TransactionResponse: The transaction response from the network, containing the transaction hash.

ParamTypeDescription
txRawTxRequestThe raw transaction request, created with createTransaction.

send({ fromAddress, toAddress, amount }): MsgProtoSend

Adds a MsgSend TxMsg for this transaction.

Returns a MsgProtoSend: An unsigned Send transaction message.

ParamTypeDescription
fromAddressstringOrigin address, which is the address that the signer holds.
toAddressstringDestination address
amountstringAmount of uPOKT to send.

appStake({ appPubKey, chains, amount }): MsgProtoAppStake

Adds a MsgAppStake TxMsg for this transaction.

Returns a MsgProtoAppStake: The unsigned App Stake message.

ParamTypeDescription
appPubKeystringApplication Public Key
chainsstring[]Chains that the apps wants access to by staking POKT. Throughput will be equally divided through all chains.
amountstringAmount of uPOKT to stake.

appUnstake(address): MsgProtoAppUnstake

Adds a MsgProtoAppUnstake TxMsg for this transaction.

Returns MsgProtoAppUnstake: The unsigned app unstake message.

ParamTypeDescription
addressstringAddress of the account.

nodeStake({ nodePubKey, chains, amount, serviceURL }): MsgProtoNodeStakeTx

Adds a NodeStake TxMsg for this transaction.

Returns a MsgProtoNodeStakeTx: The unsigned node stake message.

ParamTypeDescription
nodePubKeystringNode Public Key
chainsstring[]Chains that the node wants to service to by staking POKT.
amountstringAmount of uPOKT to stake.
serviceURLURLNode service URL that will be used to send requests through.

nodeUnstake(address): MsgProtoNodeUnstake

Adds a MsgProtoNodeUnstake for this transaction.

Returns MsgProtoNodeUnstake: The unsigned node unstake message.

ParamTypeDescription
addressstringAddress of the account.

nodeUnjail(address): MsgAProtoNodeUnjail

Adds a MsgUnjail for this transaction.

Returns a MsgProtoNodeUnstake: The unsigned node unjail message.

ParamTypeDescription
addressstringAddress of the account.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 21

Native requirements
21 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
long
Environment
{
  "local_name": "long",
  "alias": false,
  "peer_metadata": null
}
^5.2.0runtime
buffer
Environment
{
  "local_name": "buffer",
  "alias": false,
  "peer_metadata": null
}
^6.0.3runtime
varint
Environment
{
  "local_name": "varint",
  "alias": false,
  "peer_metadata": null
}
^6.0.0runtime
ts-proto
Environment
{
  "local_name": "ts-proto",
  "alias": false,
  "peer_metadata": null
}
^1.110.4runtime
protobufjs
Environment
{
  "local_name": "protobufjs",
  "alias": false,
  "peer_metadata": null
}
6.8.8runtime
@tendermint/belt
Environment
{
  "local_name": "@tendermint/belt",
  "alias": false,
  "peer_metadata": null
}
^0.3.0runtime
@pokt-network/amino-js
Environment
{
  "local_name": "@pokt-network/amino-js",
  "alias": false,
  "peer_metadata": null
}
^0.7.5-alpha.1runtime
@0xbigboss/pocketjs-types
Environment
{
  "local_name": "@0xbigboss/pocketjs-types",
  "alias": false,
  "peer_metadata": null
}
2.1.0runtime
@0xbigboss/pocketjs-utils
Environment
{
  "local_name": "@0xbigboss/pocketjs-utils",
  "alias": false,
  "peer_metadata": null
}
2.1.0runtime
@0xbigboss/pocketjs-signer
Environment
{
  "local_name": "@0xbigboss/pocketjs-signer",
  "alias": false,
  "peer_metadata": null
}
2.1.0runtime
@0xbigboss/pocketjs-abstract-provider
Environment
{
  "local_name": "@0xbigboss/pocketjs-abstract-provider",
  "alias": false,
  "peer_metadata": null
}
2.1.0runtime
jest
Environment
{
  "local_name": "jest",
  "alias": false,
  "peer_metadata": null
}
^27.4.7development
eslint
Environment
{
  "local_name": "eslint",
  "alias": false,
  "peer_metadata": null
}
7.32.0development
ts-jest
Environment
{
  "local_name": "ts-jest",
  "alias": false,
  "peer_metadata": null
}
^27.1.3development
prettier
Environment
{
  "local_name": "prettier",
  "alias": false,
  "peer_metadata": null
}
^2.5.1development
@types/jest
Environment
{
  "local_name": "@types/jest",
  "alias": false,
  "peer_metadata": null
}
^27.4.0development
microbundle
Environment
{
  "local_name": "microbundle",
  "alias": false,
  "peer_metadata": null
}
^0.14.2development
prettier-eslint
Environment
{
  "local_name": "prettier-eslint",
  "alias": false,
  "peer_metadata": null
}
^13.0.0development
@typescript-eslint/parser
Environment
{
  "local_name": "@typescript-eslint/parser",
  "alias": false,
  "peer_metadata": null
}
^5.10.2development
@0xbigboss/pocketjs-provider
Environment
{
  "local_name": "@0xbigboss/pocketjs-provider",
  "alias": false,
  "peer_metadata": null
}
2.1.0development
@typescript-eslint/eslint-plugin
Environment
{
  "local_name": "@typescript-eslint/eslint-plugin",
  "alias": false,
  "peer_metadata": null
}
^5.10.2development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "46a16262c6a9e0c3e7077d37135747f72ad72641",
  "tarball": "https://registry.npmjs.org/@0xbigboss/pocketjs-transaction-builder/-/pocketjs-transaction-builder-2.1.0.tgz",
  "fileCount": 101,
  "integrity": "sha512-0kAeE303VtxDCerEr8051PUbS2BuUg5NfqhjoxefTkafcLKr/ixE+3rxrSACKRM1i0oUq8rBqu4uphBSW4xTlA==",
  "signatures": [
    {
      "sig": "MEYCIQDPhBWkYTboKDGYq33CWnIROb5Na+y7DCZQx8hbJi0bPgIhANNZbtSNCqCUtNRgN2u8k/1bhi6nrVu8VqLse7NcangZ",
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"
    }
  ],
  "unpackedSize": 496278,
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjORLyACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqLbg//aGowCO4Wu6zBwbPGvHK5CD5Hby1vnihScfimm1N9s9/tlIQE\r\nadUSpYrMAmSZXHCs9c6bX9ZfAcXxL7v6nwebl6CMqACB9sdh6rS6abuSxnAU\r\nZD74bz6t9OasR5kFCTLqMJkxx+yr3cRh79bDtXyTATYAkxjxNGt3iXoqLCCg\r\nA4duoSZ5GSRs59C/mB20znmbEbAO1Sek9pNFY/E91lrtXtGxXV9HOC3CxiDW\r\nZrm4oQYItyPnPcpAAGetG6OgO2PpTTVANpOp0ZJUQwqTeLh+eOpy/OVILmuL\r\naBpm6Sb5OtPRyfiAsxw7jrub6uHfpsCgAKZ0dmigxL0Rx3d8bL8w8l75V6+K\r\nIO2A8+ZtcYQhcb8/n6UoLL6xQHIWj0TfGhDuy8uc8LNX99z80ozjSVvYT25f\r\nAHjkQPVCni9869oEqjHAzkV51QziPeWV4CyMj3NmRH0f8FX0XYlrikjZ0Ow6\r\ntDSs7pcqy2/q7+VzG9JcM8OmbvQMWdO64inuMh03UGha0/4+pqAYgzVir0cs\r\ngNMk/XCiAn+VEsMNasxraK3ek+hAJMqyWlYhsyqcFqdmRwvHIv6Zu3M6fPKS\r\nmDgMIqQ/K9K7n860zDR7K/VgIpKYG7VJ1j+kgbilgC87sgk+sCqX9qMBnEpD\r\nThHzbMiXhu/zfr31g1xF3eCdWJxeQ6JxFY0=\r\n=MCoq\r\n-----END PGP SIGNATURE-----\r\n"
}

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 22:43 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:7f2ecd481df209c846f1a0be1144b85c684999662fefd4ea526ed3c652fe68a4

Other collected versions

2.1.130 OctView all collected versions →