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 create a wallet you can use forc wallet new
. 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 created a wallet, you can derive a new account by running forc wallet account new
. It will ask your password to decrypt the wallet before deriving 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, 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
.
To install forc-wallet
please refer to forc-wallet
's GitHub repo.
- Construct the transaction by using either
forc deploy
orforc run
. To do so simply runforc deploy
orforc 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. - Take the transaction ID generated in the first step and sign it with
forc wallet sign --account <account_index> tx-id <transaction_id>
. This will generate a signature. - Take the signature generated in the second step and provide it to
forc-deploy
(orforc-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
accounts
command.
forc wallet accounts
- 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 want to sign the transaction generated by
forc-deploy
orforc-run
with an account funded by default once you start your local node, you can pass--default-signer
to them. Please note that this will only work against your local node.forc-deploy --default-signer
forc-run --default-signer
By default --default-signer
flag would sign your transactions with the following private-key:
0xde97d8624a438121b86a1956544bd72ed68cd69f2c99555b08b1e8c51ffd511c
Interacting with the testnet
To interact with the latest testnet, use the --testnet
flag. When this flag is passed, transactions created by forc-deploy
will be sent to the beta-4
testnet.
forc-deploy --testnet
It is also possible to pass the exact node URL while using forc-deploy
or forc-run
which can be done using --node-url
flag.
forc-deploy --node-url https://beta-3.fuel.network
Another alternative is the --target
option, which provides useful aliases to all targets. For example if you want to deploy to beta-3
you can use:
forc-deploy --target beta-3
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.
Deployment Artifacts
forc-deploy saves the details of each deployment in the out/deployments
folder within the project's root directory. Below is an example of a deployment artifact:
{
"transaction_id": "0xec27bb7a4c8a3b8af98070666cf4e6ea22ca4b9950a0862334a1830520012f5d",
"salt": "0x9e35d1d5ef5724f29e649a3465033f5397d3ebb973c40a1d76bb35c253f0dec7",
"network_endpoint": "http://127.0.0.1:4000",
"chain_id": 0,
"contract_id": "0x767eeaa7af2621e637f9785552620e175d4422b17d4cf0d76335c38808608a7b",
"deployment_size": 68,
"deployed_block_id": "0x915c6f372252be6bc54bd70df6362dae9bf750ba652bf5582d9b31c7023ca6cf"
}