Skip to main content

eth_signTransaction

Signs a transaction using an unlocked account on the node. Important: Most RPC providers don't support this method for security reasons, as it requires private keys to be stored on the server.

Security Considerations#

  • This method requires an unlocked account on the node
  • Private keys must be available to the RPC server
  • Most production RPC providers disable this method
  • Use client-side signing libraries instead for better security

Parameters#

  1. Object - The transaction object:
    • from: DATA, 20 Bytes - The address the transaction is sent from
    • to: DATA, 20 Bytes - (optional) The address the transaction is directed to
    • gas: QUANTITY - (optional) Integer of the gas provided for the transaction execution
    • gasPrice: QUANTITY - (optional) Integer of the gasPrice used for each paid gas
    • value: QUANTITY - (optional) Integer of the value sent with this transaction
    • data: DATA - (optional) The compiled code of a contract OR the hash of the invoked method signature and encoded parameters

Returns#

DATA - The signed transaction data, ready for transmission via eth_sendRawTransaction.

Implementation Example#

Heads up

eth_signTransaction requires access to an unlocked account, which Dwellir's shared RPC endpoints do not provide. Sign the payload locally (wallet, HSM, or KMS) and then broadcast with eth_sendRawTransaction.

const response = await fetch('https://api-centrifuge.n.dwellir.com/YOUR_API_KEY', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: '2.0',
method: 'eth_signTransaction',
params: [{
from: '0x9b2055d370f73ec7d8a03e965129118dc8f5bf83',
to: '0xd46e8dd67c5d32be8058bb8eb970870f07244567',
gas: '0x76c0',
gasPrice: '0x9184e72a000',
value: '0x9184e72a'
}],
id: 1
})
});

const data = await response.json();
console.log(data.result);

Response Example#

{
"jsonrpc": "2.0",
"id": 1,
"result": "0xf86c808504a817c8008276c094d46e8dd67c5d32be8058bb8eb970870f072445675849184e72a8001ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804"
}

Note: This method is typically not available on hosted RPC providers for security reasons. The response shows a signed transaction ready for broadcast.


Need help? Contact our support team or check the Centrifuge documentation.