Perform
Usage: forc call [OPTIONS]
[FUNCTION] [FUNCTION_ARGS]...Options:
--abi
<ABI>
Path or URI to a JSON ABI file Required when making function calls or listing functions
--node-url
<NODE_URL>
The URL of the Fuel node to which we're submitting the transaction. If unspecified, checks the manifest's network
table, then falls back to http://127.0.0.1:4000
You can also use --target
, --devnet
, --testnet
, or --mainnet
to specify the Fuel node.
[env: FUEL_NODE_URL=]
--target
<TARGET>
Preset configurations for using a specific target.
You can also use --node-url
, --devnet
, --testnet
, or --mainnet
to specify the Fuel node.
Possible values are: [local, testnet, mainnet]
--mainnet
Use preset configuration for mainnet.
You can also use --node-url
, --target
, or --testnet
to specify the Fuel node.
--testnet
Use preset configuration for testnet.
You can also use --node-url
, --target
, or --mainnet
to specify the Fuel node.
--devnet
Use preset configuration for devnet.
You can also use --node-url
, --target
, or --testnet
to specify the Fuel node.
--gas-price
<PRICE>
Gas price for the transaction
--script-gas-limit
<SCRIPT_GAS_LIMIT>
Gas limit for the transaction
--max-fee
<MAX_FEE>
Max fee for the transaction
--tip
<TIP>
The tip for the transaction
-h
, --help
Print help (see a summary with '-h')
-V
, --version
Print version
CONTRACT:
--external-contracts
<EXTERNAL_CONTRACTS>
The external contract addresses to use for the call If none are provided, the call will automatically populate external contracts by making a dry-run calls to the node, and extract the contract addresses based on the revert reason
<ADDRESS> The contract ID to call
FUNCTION: [FUNCTION] The function selector to call. The function selector is the name of the function to call (e.g. "transfer"). Not required when --list-functions is specified or when --amount is provided for direct transfer
[FUNCTION_ARGS]... Arguments to pass to the function
ACCOUNT OPTIONS:
--signing-key
<SIGNING_KEY>
Derive an account from a secret key to make the call
[env: SIGNING_KEY=]
--wallet
Use forc-wallet to make the call
CALL PARAMETERS:
--amount
<AMOUNT>
Amount of native assets to forward with the call
[default: 0]
--asset-id
<ASSET_ID>
Asset ID to forward with the call
--gas-forwarded
<GAS_FORWARDED>
Amount of gas to forward with the call
EXECUTION:
--mode
<MODE>
Execution mode - determines if state changes are applied - dry-run
: No state changes, no gas fees, wallet is not used or validated - simulate
: No state changes, estimates gas, wallet is used but not validated - live
: State changes, gas fees apply, wallet is used and validated
[default: dry-run]
Possible values:
- dry-run: Execute a dry run - no state changes, no gas fees, wallet is not used or validated
- simulate: Execute in simulation mode - no state changes, estimates gas, wallet is used but not validated
- live: Execute live on chain - state changes, gas fees apply, wallet is used and validated
OPERATION:
--list-functions
List all available functions in the contract
OUTPUT:
--output
<OUTPUT>
Output format for the call result
[default: default]
Possible values:
- default: Default formatted output
- raw: Raw unformatted output
-v...
Set verbosity levels; currently only supports max 2 levels - -v=1
: Print decoded logs - -v=2
: Additionally print receipts and script json
EXAMPLES:
Call a contract with function parameters
» forc call 0x0dcba78d7b09a1f77353f51367afd8b8ab94b5b2bb6c9437d9ba9eea47dede97 \
--abi
./contract-abi.json
get_balance 0x0087675439e10a8351b1d5e4cf9d0ea6da77675623ff6b16470b5e3c58998423
Call a contract with function parameters; additionally print logs, receipts and script json
» forc call 0x0dcba78d7b09a1f77353f51367afd8b8ab94b5b2bb6c9437d9ba9eea47dede97 \
--abi
./contract-abi.json
get_balance 0x0087675439e10a8351b1d5e4cf9d0ea6da77675623ff6b16470b5e3c58998423 \
-vv
Call a contract without function parameters
» forc call 0x0dcba78d7b09a1f77353f51367afd8b8ab94b5b2bb6c9437d9ba9eea47dede97 \
--abi
./contract-abi.json
get_name
Call a contract that makes external contract calls
» forc call 0x0dcba78d7b09a1f77353f51367afd8b8ab94b5b2bb6c9437d9ba9eea47dede97 \
--abi
./contract-abi.json
transfer 0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07 \
--contracts
0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07
Call a contract in simulation mode
» forc call 0x0dcba78d7b09a1f77353f51367afd8b8ab94b5b2bb6c9437d9ba9eea47dede97 \
--abi
./contract-abi.json
add 1 2 \
--mode
simulate
Call a contract in dry-run mode on custom node URL using explicit signing-key
» forc call 0x0dcba78d7b09a1f77353f51367afd8b8ab94b5b2bb6c9437d9ba9eea47dede97 \
--node-url
"http://127.0.0.1:4000/v1/graphql" \
--signing-key
0x... \
--abi
./contract-abi.json
add 1 2 \
--mode
dry-run
Call a contract in live mode which performs state changes on testnet using forc-wallet
» forc call 0x0dcba78d7b09a1f77353f51367afd8b8ab94b5b2bb6c9437d9ba9eea47dede97 \
--testnet
\
--wallet
\
--abi
./contract-abi.json
add 1 2 \
--mode
live
Call a contract payable function which transfers value of native asset on mainnet
» forc call 0x0dcba78d7b09a1f77353f51367afd8b8ab94b5b2bb6c9437d9ba9eea47dede97 \
--abi
./contract-abi.json
transfer 0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07 \
--mode
live \
--amount
100
Call a contract payable function which transfers value of custom asset
» forc call 0x0dcba78d7b09a1f77353f51367afd8b8ab94b5b2bb6c9437d9ba9eea47dede97 \
--abi
./contract-abi.json
transfer 0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07 \
--amount
100 \
--asset-id
0x0087675439e10a8351b1d5e4cf9d0ea6da77675623ff6b16470b5e3c58998423 \
--live
List all available functions in a contract
» forc call 0x0dcba78d7b09a1f77353f51367afd8b8ab94b5b2bb6c9437d9ba9eea47dede97 \
--abi
./contract-abi.json \
--list-functions
Direct transfer of asset to a contract or address
» forc call 0x0dcba78d7b09a1f77353f51367afd8b8ab94b5b2bb6c9437d9ba9eea47dede97 \
--amount
100 \
--mode
live