call
Executes a new message call immediately without submitting a transaction to the network.
Usage
example.ts
import { account, publicClient } from "./config";
const data = await publicClient.call({
account,
data: "0x",
to: "cfx:...",
});
Returns
The call data.
Parameters
account
- Type:
Account | Address
The Account to call from.
Accepts Local Account (Private Key, etc).
export const account = privateKeyToAccount("0x...", { networkId: mainnet.id });
const data = await publicClient.call({
account: account,
data: "0x",
to: "cfx:...",
});
const data = await publicClient.call({
account: "cfx:...",
data: "0x",
to: "cfx:...",
});
to
- Type:
Address
The contract address or recipient.
const data = await publicClient.call({
account: "cfx:...",
data: "0x",
to: "cfx:...",
});
gasPrice (optional)
- Type:
bigint
The price (in drip) to pay per gas. Only applies to Legacy Transactions.
import { parseGDrip } from "cive";
const data = await publicClient.call({
account: "cfx:...",
data: "0x",
to: "cfx:...",
gasPrice: parseGDrip("20"),
});
gas (optional)
- Type:
bigint
The gas provided for transaction execution.
const data = await publicClient.call({
account: "cfx:...",
data: "0x",
to: "cfx:...",
gas: 1_000_000n,
});
value (optional)
- Type:
bigint
Value (in drip) sent with this transaction.
import { parseCFX } from "cive";
const data = await publicClient.call({
account: "cfx:...",
data: "0x",
to: "cfx:...",
value: parseCFX("1"),
});
factoryData (optional)
- Type:
Calldata to execute on the factory to deploy the contract.
const data = await publicClient.call({
account: "cfx:...",
data: "0x",
to: "cfx:...",
});
nonce (optional)
- Type:
bigint
Unique number identifying this transaction.
const data = await publicClient.call({
account: "cfx:...",
nonce: 1,
to: "cfx:...",
});
accessList (optional)
- Type:
AccessList
The access list.
const data = await publicClient.call({
account: "cfx:...",
to: "cfx:...",
accessList: [
{
address: "cfx:...",
storageKeys: ["0x1"],
},
],
});
maxFeePerGas (optional)
- Type:
bigint
Total fee per gas (in drip), inclusive of maxPriorityFeePerGas
.
import { parseGDrip } from "cive";
const data = await publicClient.call({
account: "cfx:...",
to: "cfx:...",
maxFeePerGas: parseGDrip("20"),
});
maxPriorityFeePerGas (optional)
- Type:
bigint
Max priority fee per gas (in drip).
import { parseGDrip } from "cive";
const data = await publicClient.call({
account: "cfx:...",
to: "cfx:...",
maxFeePerGas: parseGDrip("20"),
maxPriorityFeePerGas: parseGDrip("2"),
});