I am new to json RPC and Ethereum. I am trying to query 2 JSON RPC methods

eth_sendTransaction method

        "from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
        "to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
        "gas": "0x76c0",
        "gasPrice": "0x9184e72a000",
        "value": "0x9184e72a",
        "data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"

this is working fine, similarly their is a eth_sendRawTransaction method this method accepts bytes as an parameter


I am not sure how can I convert the params from eth_sendTransaction method to bytes such that it can be used in eth_sendRawTransaction?

Any help, pointer, clues are really appreciated.

  • I am not familiar with your use case and do not understand the context where you have to perform such operations. To start with ethereum development take a look on Remix IDE and hardhat. At this moment I ended up with Visual Studio Code and hardhat for my project.
    – Gleichmut
    Commented Sep 8, 2022 at 11:34
  • I am trying to use the JSON RPC exposed by ETH clients.
    – nunam
    Commented Sep 9, 2022 at 5:30

1 Answer 1


eth_sendRawTransaction accepts a signed transaction as input parameter.

For example you could use a library like @ethereumjs/tx to sign a transaction.

import { Chain, Common, Hardfork } from '@ethereumjs/common'
import { Transaction } from '@ethereumjs/tx'

const txParams = {
  nonce: '0x42',
  gasPrice: '0x09184e72a000',
  gasLimit: '0x2710',
  to: '0x0000000000000000000000000000000000000042',
  value: '0x00',
  data: '0x486F6C612121',

const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.Istanbul })
const tx = Transaction.fromTxData(txParams, { common })

const privateKey = Buffer.from(

const signedTx = tx.sign(privateKey)

const serializedTx = signedTx.serialize()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.