Skip to content
Cive

sendTransaction

Creates, signs, and sends a new transaction to the network.

Usage

import { ,  } from "./config";
 
const  = await .({
  ,
  : "cfx:...",
  : 1000000000000000000n,
});
// '0x...'

Account Hoisting

If you do not wish to pass an account to every sendTransaction, you can also hoist the Account on the Wallet Client (see config.ts).

Learn more.

import {  } from "./client";
 
const  = await .({
  : "cfx:...",
  : 1000000000000000000n,
});
// '0x...'

Returns

Hash

The Transaction hash.

Parameters

account

  • Type: Account | Address

The Account to send the transaction from.

Accepts a JSON-RPC Account or Local Account (Private Key, etc).

const  = await .({
  : "cfx:...", 
  : "cfx:...",
  : 1000000000000000000n,
});

to

  • Type: 0x${string}

The transaction recipient or contract address.

const  = await .({
  ,
  : "cfx:...", 
  : 1000000000000000000n,
  : 1,
});

accessList (optional)

The access list.

const  = await .({
  : [
    {
      : "0x1",
      : ["0x1"],
    },
  ],
  ,
  : "cfx:...",
});

data (optional)

  • Type: 0x${string}

A contract hashed method call with encoded args.

const  = await .({
  : "cfx:...", 
  ,
  : "cfx:...",
  : 1000000000000000000n,
});

gasPrice (optional)

  • Type: bigint

The price (in wei) to pay per gas. Only applies to Legacy Transactions.

import { ,  } from "cive/utils";
 
const  = await .({
  ,
  : ("20"), 
  : "cfx:...",
  : ("1"),
});

maxFeePerGas (optional)

  • Type: bigint

Total fee per gas (in wei), inclusive of maxPriorityFeePerGas. Only applies to EIP-1559 Transactions

import { ,  } from "cive/utils";
const  = await .({
  ,
  : ("20"), 
  : "cfx:...",
  : ("1"),
});

maxPriorityFeePerGas (optional)

  • Type: bigint

Max priority fee per gas (in wei). Only applies to EIP-1559 Transactions

import { ,  } from "cive/utils";
const  = await .({
  ,
  : ("20"),
  : ("2"), 
  : "cfx:...",
  : ("1"),
});

nonce (optional)

  • Type: number

Unique number identifying this transaction.

const  = await .({
  ,
  : "cfx:...",
  : 1000000000000000000n,
  : 1, 
});

value (optional)

  • Type: bigint

Value in wei sent with this transaction.

import { ,  } from "cive/utils";
const  = await .({
  ,
  : "cfx",
  : ("1"), 
  : 1,
});

Tips

  • For dapps: When using this action, it is assumed that the user has connected to their wallet (e.g. given permission for the dapp to access their accounts via requestAddresses). You can also check if the user has granted access to their accounts via getAddresses

JSON-RPC Methods