Skip to main content

Web3Signer JSON-RPC API

note
  • All JSON-RPC HTTP examples use the default host and port endpoint http://127.0.0.1:8545.
  • The examples use Hyperledger Besu, but you can use any Ethereum execution client.

eth_accounts

Returns the account address with which Web3Signer is signing transactions.

Returns multiple accounts if multiple signers are configured.

Parameters

None

Returns

Array of data - Account address with which Web3Signer is signing transactions

curl -X POST --data '{"jsonrpc":"2.0","method":"eth_accounts","params":[],"id":1}' http://127.0.0.1:8545

eth_sign

Calculates an Ethereum specific signature using sign(keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)))."

Adds a prefix to the message that makes the calculated signature recognizable as an Ethereum specific signature. This prevents malicious dapps from signing arbitrary data (for example, a transaction) and using the signature to impersonate the victim.

Parameters

DATA - 20-byte account address

DATA - Data string to sign

Returns

DATA - Signature

curl -X POST --data '{"jsonrpc":"2.0","method":"eth_sign","params":["0x78e6e236592597c09d5c137c2af40aecd42d12a2", "0x2eadbe1f"], "id":1}' http://127.0.0.1:8545

eth_signTransaction

Signs a transaction that you can submit to Besu at a later time using eth_sendRawTransaction.

Parameters

Transaction object:

KeyTypeRequired/OptionalValue
fromData, 20 bytesRequiredAddress of the sender.
toData, 20 bytesOptional for contract creationAddress of the receiver. null if this is a contract creation transaction.
gasQuantityOptionalGas provided by the sender. The default is 90000.
gasPriceQuantityOptionalGas price provided by the sender in Wei. The default is 0. Used only in non EIP-1559 transactions.
maxPriorityFeePerGasQuantityOptionalMaximum fee, in Wei, the sender is willing to pay above the base fee. Used only in EIP-1559 transactions.
maxFeePerGasQuantityOptionalMaximum total fee (base fee + priority fee), in Wei, the sender is willing to pay. Used only in EIP-1559 transactions.
nonceQuantityOptionalNumber of transactions made by the sender before this one. Must be specified if using GoQuorum.
valueQuantityOptionalValue transferred in Wei.
dataQuantityOptionalCompiled contract code or hash of the invoked method signature and encoded parameters.

Returns

result : data - The signed transaction object.

curl -X POST --data '{"jsonrpc":"2.0","method":"eth_signTransaction","params":[{"from": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73","to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567","gas": "0x7600","gasPrice": "0x9184e72a000","value": "0x9184e72a", "nonce":"0x46"}], "id":1}' http://127.0.0.1:8545

eth_sendTransaction

Creates and signs a transaction using the signing key.

EthSigner submits the signed transaction to Besu using eth_sendRawTransaction.

Parameters

Transaction object:

KeyTypeRequired/OptionalValue
fromData, 20 bytesRequiredAddress of the sender.
toData, 20 bytesOptional for contract creationAddress of the receiver. null if this is a contract creation transaction.
gasQuantityOptionalGas provided by the sender. The default is 90000.
gasPriceQuantityOptionalGas price provided by the sender in Wei. The default is 0. Used only in non EIP-1559 transactions.
maxPriorityFeePerGasQuantityOptionalMaximum fee, in Wei, the sender is willing to pay above the base fee. Used only in EIP-1559 transactions.
maxFeePerGasQuantityOptionalMaximum total fee (base fee + priority fee), in Wei, the sender is willing to pay. Used only in EIP-1559 transactions.
nonceQuantityOptionalNumber of transactions made by the sender before this one. Must be specified if using GoQuorum.
valueQuantityOptionalValue transferred in Wei.
dataQuantityOptionalCompiled contract code or hash of the invoked method signature and encoded parameters.
tip

Submitting a transaction with the same nonce as a pending transaction and a higher gas price replaces the pending transaction with the new one.

Returns

result : data - 32-byte transaction hash

curl -X POST --data '{"jsonrpc":"2.0","method":"eth_sendTransaction","params":[{"from": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73","to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567","gas": "0x7600","gasPrice": "0x9184e72a000","value": "0x9184e72a"}], "id":1}' http://127.0.0.1:8545