Funding Your Wallet
In this tutorial we learn how to fund your wallet using the brambl-cli. We
assume here that the wallet is already initialized and the funds are locked
by a height lock threshold(1, height(1, 9223372036854775807))
.
Initialize a Wallet
To initialize a wallet, you need to run the following command:
brambl-cli wallet init -w $PASSWORD --passphrase $PASSPHRASE -n $NETWORK -o keyfile.json --newwalletdb wallet.db --mnemonicfile mnemonic.txt
This will create a new wallet with a new master key protected by a password and a passphrase. The wallet will be stored in the file specified by the --newwalletdb
option. The mnemonic will be stored in the file specified by the --mnemonicfile
option. The master key will be stored in the file specified by the -o
option. The valid values for the -n
option are mainnet
, testnet
, and private
.
Getting Your Address
To get the current address of the wallet run the following command:
brambl-cli wallet current-address --walletdb wallet.db --from-fellowship self --from-template default --from-interaction 1
If you have several interactions already in your wallet, you can just omit the --from-interaction
parameter and the CLI will use the last interaction of the template default
.
We are using the fellowship self
which is included in the wallet by default
and the template default
which is also included in the wallet by default.
self
is a fellowship that only contains one fellow, the owner of the wallet.
default
is a template that correspond to the quivr contract threshold(1, sign(0))
.
The interaction 1
is the first interaction of the template default
. If you
have several interactions already in your wallet, you can just omit the --from-interaction
parameter and the CLI will use the last interaction of the template default
.
We use the address we get to create the transaction as $TO_ADDRESS
.
Create the Transaction
To create a simple transaction you need to run the following command:
brambl-cli simple-transaction create --from-fellowship nofellowship --from-template genesis --from-interaction 1 -t $TO_ADDRESS -w $PASSWORD --port $PORT -o genesisTx.pbuf -n $NETWORK -a $SEND_AMOUNT -h $HOST -i keyfile.json --walletdb wallet.db --fee $FEE --transfer-token lvl
This will create a transaction that spends the interaction 1
of the template genesis
of the fellowship nofellowship
and sends $SEND_AMOUNT
levels to the address $TO_ADDRESS
. The transaction will be stored in the file genesisTx.pbuf
.
Prove the Transaction
To prove a transaction run the following command:
brambl-cli tx prove -w $PASSWORD --keyfile keyfile.json -i genesisTx.pbuf -o genesisTxProved.pbuf --walletdb wallet.db
This will prove the transaction in the file genesisTx.pbuf
and store the result in the file genesisTxProved.pbuf
. The right indexes to derive the keys are taken from the wallet database.
Broadcast the Transaction
To broadcast a simple transaction run the following command:
brambl-cli tx broadcast -i genesisTxProved.pbuf -h $HOST --port $PORT
This will broadcast the transaction in the file genesisTxProved.pbuf
to the network.
Check the Balance
You can check the balance of an address using the following command:
brambl-cli wallet balance --from-fellowship self --from-template default --walletdb wallet.db --host $HOST --port $PORT
This will show you the balance of the address self
and default
in the wallet wallet.db
in the node $HOST:$PORT
. The --from-interaction
can optionally be used to choose the interaction.
The result should be:
LVL: 1000
Find more information here! Brambl-cli Documentation