forc-client

Forc plugin for interacting with a Fuel node.

Initializing the wallet and adding accounts

If you don't have an initialized wallet or any account for your wallet you won't be able to sign transactions.

To initialize a wallet you can use forc wallet init. It will ask you to choose a password to encrypt your wallet. After the initialization is done you will have your mnemonic phrase.

After you have an initialized wallet, you can create an account for it by simply running forc wallet new. It will ask your password to decrypt the wallet before creating an account.

Signing transactions using forc-wallet CLI

To submit the transactions created by forc deploy or forc run, you need to sign them first (unless you are using a client without UTXO validation). To sign a transaction you can use forc-wallet CLI. This section is going to walk you through the whole signing process.

By default fuel-core runs without UTXO validation, which means you can run unsigned transactions. This allows you to send invalid inputs to emulate different conditions.

If you want to run fuel-core with UTXO validation, you can pass --utxo-validation to fuel-core run. If UTXO validation is enabled, unsigned transactions will return an error.

To install forc-wallet please refer to forc-wallet's github repo.

  1. Construct the transaction by using either forc deploy or forc run. To do so simply run forc deploy or forc run with your desired parameters. For a list of parameters please refer to the forc-deploy or forc-run section of the book. Once you run either command you will be asked the address of the wallet you are going to be signing with. After the address is given the transaction will be generated and you will be given a transaction ID. At this point CLI will actively wait for you to insert the signature.
  2. Take the transaction ID generated in the first step and sign it with forc wallet sign <transaction_id> <account_index>. This will generate a signature.
  3. Take the signature generated in the second step and provide it to forc-deploy (or forc-run). Once the signature is provided, the signed transaction will be submitted.

Other useful commands of forc-wallet

  • You can see a list of existing accounts with list command.
forc wallet list
  • If you want to retrieve the address for an account by its index you can use account command.
forc wallet account <account_index>

If you don't want to sign the transaction generated by forc-deploy or forc-run you can pass --unsigned to them.

forc-deploy --unsigned
forc-run --unsigned

Interacting with the testnet

While using forc-deploy or forc-run to interact with the testnet you need to pass the testnet end point with --url

forc-deploy --url https://node-beta-1.fuel.network/graphql:443

Since deploying and running projects on the testnet cost gas, you will need coins to pay for them. You can get some using the testnet faucet.

Also the default value of the "gas price" parameter is 0 for both forc-deploy and forc-run. Without changing it you will get an error complaining about gas price being too low. While using testnet you can pass --gas-price 1 to overcome this issue. So a complete command for deploying to the testnet would look like:

forc-deploy --url https://node-beta-1.fuel.network/graphql:443 --gas-price 1