Send transaction
This chapter will describe in detail the methods and parameters of sending transactions. A transaction is a formal action on the blockchain. They are always started in the TokenPocket Extension by calling the eth_sendTransaction
method. They may involve simple ether sending, also may result in sending tokens, creating new smart contracts, and many other ways to change state on the blockchain. They are always initiated by a signature or simple key pair from an external account.
In the TokenPocket Extension, ethereum.request can be used directly, and sending a transaction would involve assembling an options object like this:
example
Trading parameters
TokenPocket Extension handles many trading parameters for you, but it is good to know what all parameters do.
Nonce [ignore]
This field is ignored by TokenPocket Extension
In Ethereum every transaction has a nonce. This is so that each transaction can only be processed by the blockchain once. Additionally, to be a valid transaction, the nonce must either be 0, or a transaction with the previous number must have already been processed.
That means that transactions are always processed for a given account, and so incrementing nonces is a very sensitive matter that is easy to mess up, especially when a user is interacting with multiple applications with pending transactions using the same account, potentially across multiple devices.
For these reasons, TokenPocket Extension currently does not provide application developers any way to customize the nonce of transactions it suggests.
Gas Price [optional]
Optional parameter - best used on private blockchains.
In Ethereum, every transaction specifies a price for the gas that it will consume. To maximize their profit, block producers will pick pending transactions with higher gas prices first when creating the next block. This means that a high gas price will usually cause your transaction to be processed faster, at the cost of greater transaction fees. Note that this may not be true for Layer 2 networks, which may have a constant gas price or no gas price at all.
In other words, while you can ignore this parameter on TokenPocket Extension default networks, you may want to include it in situations where your application knows more about the target network than we do. On our default networks, TokenPocket Extension allows users to choose between "slow," "medium," and "fast" options for their gas price.
Gas Limit [optional]
Optional parameter. Rarely useful to Dapp developers.
Gas limit is a highly optional parameter, and we automatically calculate a reasonable price for it. You will probably know that your smart contract benefits from a custom gas limit if it ever does for some reason.
To [semi-optional]
A hex-encoded Ethereum address. Required for transactions with a recipient (all transactions except for contract creation).
Value [optional]
Hex-encoded value of the network's native currency to send. On the Main Ethereum network, this is ether , which is denominated in wei, i.e, 1e-18 ether.
Please note that these numbers often used in Ethereum are far higher precision than native JavaScript numbers, and can cause unpredictable behavior if not anticipated. For this reason, we highly recommend using BN.js when manipulating values intended for the blockchain.
Data [semi-optional]
Required for smart contract creation.
This field is also used for specifying contract methods and their parameters. You can learn more about how that data is encoded on the solidity ABI spec
Chain ID [currently ignored]
Chain ID is currently derived by the user's current selected network at ethereum.networkVersion
Last updated