Skip to main content

Create and send transactions

You can send signed transactions using the eth_sendRawTransaction JSON-RPC API method.

Signed transactions can be simple value transfers, contract creation, or contract invocation. Set the maximum transaction fee for transactions using the --rpc-tx-feecap CLI option.

To accept signed transactions from remote connections, set the API listening host to 0.0.0.0.

Use client libraries to create and send a signed raw transaction to transfer Ether and create a smart contract.

Private keys

Don't use the accounts from the examples on Mainnet or any public network except for testing. The private keys are displayed which means the accounts are not secure.

All accounts and private keys in the examples are from the dev.json genesis file in the /besu/config/src/main/resources directory.

In production environments avoid exposing your private keys by creating signed transactions offline, or use EthSigner to isolate your private keys and sign transactions with eth_sendTransaction.

caution

Setting the listening host to 0.0.0.0 exposes the API service connection on your node to any remote connection. In a production environment, ensure you are using a firewall to avoid exposing your node to the internet.

tip

Libraries such as web3j or ethereumj and tools such as MyCrypto can also create signed transactions.

eth_call vs eth_sendRawTransaction

You can interact with contracts using eth_call or eth_sendRawTransaction. The table below compares the characteristics of both calls.

eth_calleth_sendRawTransaction
Read-onlyWrite
Invokes contract function locallyBroadcasts to the network
Does not change state of blockchainUpdates the blockchain (for example, transfers ether between accounts)
Does not consume gasRequires gas
SynchronousAsynchronous
Returns the value of a contract function available immediatelyReturns transaction hash only. A block might not include all possible transactions (for example, if the gas price is too low).

Use wallets for key management

Besu doesn't support key management inside the client. Use:

  • EthSigner with Besu to provide access to your key store and sign transactions.
  • Third-party tools (for example, MetaMask and web3j) for creating accounts.