Skip to content

eth_sendTransaction

Instructs the Wallet to broadcast a transaction to the network.

Request

type Request = {
  method: 'eth_sendTransaction',
  params: [{
    /** Target chain ID. Defaults to the connected chain. */
    chainId?: `0x${string}`,
    /** Calldata to send with the transaction. */
    data?: `0x${string}`,
    /** Address of the sender. */
    from: `0x${string}`,
    /** Address of the recipient. */
    to: `0x${string}`,
    /** Value to transfer. Defaults to 0. */
    value?: `0x${string}`,
  }]
}

Response

Transaction hash.

type Response = `0x${string}`

Example

Mint ERC20 Tokens

The example below demonstrates minting 100 EXP.

import RapidfireID from '@rapidfire/id'
 
const rapidfire = new RapidfireID()
const provider = rapidfire.getEthereumProvider()
import { encodeFunctionData, parseAbi, parseEther } from 'viem'
 
const [account] = await provider.request({
  method: 'eth_accounts',
})
 
const hash = await provider.request({
  method: 'eth_sendTransaction',
  params: [{
    from: account,
    to: '0x706aa5c8e5cc2c67da21ee220718f6f6b154e75c',
    data: encodeFunctionData({
      abi: parseAbi([
        'function mint(address, uint256)',
      ]),
      functionName: 'mint',
      args: [account, parseEther('100')],
    }),
  }],
})

Send ETH

import RapidfireID from '@rapidfire/id'
 
const rapidfire = new RapidfireID()
const provider = rapidfire.getEthereumProvider()
 
const hash = await provider.request({
  method: 'eth_sendTransaction',
  params: [{
    from: '0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef',
    to: '0xcafebabecafebabecafebabecafebabecafebabe',
    value: '0x1',
  }],
})