Fund Accounts on Local Dijets Network
Prerequisites:#
-
You are familiar with Dijets Ternary Chain Ledger System & Architecture.
-
You have completed the tutorial for "How to run a Dijets Node"
-
You have completed the tutorial for "Create a Local Dijets Network"
-
You have Go language installed on your system with $GOBIN set to be in your path.
Fund a Local Test Network
Introduction#
In Create a Local Test Network, you learnt how to launch a 5 node local test network. Once you have a local network the next step is to fund an address so that you can begin creating transactions and interacting with smart-contracts on the said network.
This guide will show you how to leverage a pre-funded private key to access funds on the Value, Utility & Method Chains running in the local network you created.
This private key,
PrivateKey-ewoqjP7PxY4yr3iLTpLisriqt94hdyDFNgchSxGGztUrTXtNN
, can be used to
sign transactions locally using DijetsJS.
You don't need to import the key into the local keystore in order to access
those funds. They are in the genesis vertex and block for each respective chain.
The port in this tutorial uses 9650 as default. Depending on how you choose to start your local network port numbers could vary each time.
Only create a keystore user on a node that you have full access to and one that you can operate. If that node is breached, you could lose all your tokens. This tutorial makes calls to the Keystore APIs which is not recommended to be used with Dijets Mainnet.
Create a User#
You can skip this step if you are only interested in checking your balance on any of the Value, Utility or Method Chains.
Typically an account address in a network has a balance that was assigned to it either through the genesis block or through transferring from another account.
For the purpose of this guide, we will use an existing Private Key with a pre-funded address and a balance associated with it. This key
PrivateKey-ewoqjP7PxY4yr3iLTpLisriqt94hdyDFNgchSxGGztUrTXtNN
and its address was assigned a balance during the genesis block of a test network
just like the one you started previously and the one we are currently using for this tutorial.
To use the key and the balance in it, we must first create a user by making a call to the Keystore API of our locally running Dijets Node.
Run
keystore.createUser
to create a user in the local keystore.
_11curl --location --request POST '127.0.0.1:9650/ext/keystore' \_11--header 'Content-Type: application/json' \_11--data-raw '{_11 "jsonrpc":"2.0",_11 "id" :1,_11 "method" :"keystore.createUser",_11 "params" :{_11 "username": "PenXenOleFren",_11 "password": "password"_11 }_11}'
Now that you have created a user, you can import the prefunded private key
PrivateKey-ewoqjP7PxY4yr3iLTpLisriqt94hdyDFNgchSxGGztUrTXtNN
, into
any of the 3 blockchains. After importing the key you can
check the balance to confirm that it worked.
Importing the Prefunded Key into the Value Chain#
Import Key#
You can import the prefunded PrivateKey-ewoqjP7PxY4yr3iLTpLisriqt94hdyDFNgchSxGGztUrTXtNN
into the Value Chain by calling
the avm.importKey API.
_12curl --location --request POST '127.0.0.1:9650/ext/bc/V' \_12--header 'Content-Type: application/json' \_12--data-raw '{_12 "jsonrpc":"2.0",_12 "id" :1,_12 "method" :"avm.importKey",_12 "params" :{_12 "username": "PenXenOleFren",_12 "password": "password",_12 "privateKey":"PrivateKey-ewoqjP7PxY4yr3iLTpLisriqt94hdyDFNgchSxGGztUrTXtNN"_12 }_12}'
Check the Value Chain Balance#
Confirm that the X-local18jma8ppw3nhx5r4ap8clazz0dps7rv5u9xde7p
address now has a
balance of 300m DJT on the Value Chain.
_11curl --location --request POST '127.0.0.1:9650/ext/bc/V' \_11--header 'Content-Type: application/json' \_11--data-raw '{_11 "jsonrpc":"2.0",_11 "id" : 1,_11 "method" :"avm.getBalance",_11 "params" :{_11 "address":"X-local18jma8ppw3nhx5r4ap8clazz0dps7rv5u9xde7p",_11 "assetID": "DJT"_11 }_11} '
Utility Chain#
Import Key#
You can import the prefunded PrivateKey-ewoqjP7PxY4yr3iLTpLisriqt94hdyDFNgchSxGGztUrTXtNN
into the Utility Chain by calling
the djt.importKey API.
_12curl --location --request POST '127.0.0.1:9650/ext/bc/C/djt' \_12--header 'Content-Type: application/json' \_12--data-raw '{_12 "method": "djt.importKey",_12 "params": {_12 "username": "PenXenOleFren",_12 "password": "password",_12 "privateKey":"PrivateKey-ewoqjP7PxY4yr3iLTpLisriqt94hdyDFNgchSxGGztUrTXtNN"_12 },_12 "jsonrpc": "2.0",_12 "id": 1_12}'
Check the Utility Chain Balance#
Confirm the 0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC
address has a balance
of 50m (0x295be96e64066972000000 in hex) DJT on the Utility Chain.
_11curl --location --request POST 'localhost:9650/ext/bc/C/rpc' \_11--header 'Content-Type: application/json' \_11--data-raw '{_11 "jsonrpc": "2.0",_11 "method": "eth_getBalance",_11 "params": [_11 "0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC",_11 "latest"_11 ],_11 "id": 1_11}'
Integrate with MetaMask#
To see this account on MetaMask, follow these steps:
-
Set up MetaMask by using the info below:
- Network Name: Dijets Local UC
- New RPC URL: http://127.0.0.1:9650/ext/bc/C/rpc
- ChainID:
90901
- Symbol:
DJT
-
Create a new account by importing the private key
0x56289e99c94b6912bfc12adc093c9b51124f0dc54ac7a766b2bc5ccf558d8027
on MetaMask
- Now you can see the balance of this newly created account on Dijets Local Network
Method Chain#
Import Key#
You can import the prefunded PrivateKey-ewoqjP7PxY4yr3iLTpLisriqt94hdyDFNgchSxGGztUrTXtNN
into the Utility Chain by calling
the platform.importKey API.
_12curl --location --request POST '127.0.0.1:9650/ext/bc/P' \_12--header 'Content-Type: application/json' \_12--data-raw '{_12 "jsonrpc":"2.0",_12 "id" :1,_12 "method" :"platform.importKey",_12 "params" :{_12 "username": "PenXenOleFren",_12 "password": "password",_12 "privateKey":"PrivateKey-ewoqjP7PxY4yr3iLTpLisriqt94hdyDFNgchSxGGztUrTXtNN"_12 }_12}'
Check Method Chain Balance#
Confirm the P-custom18jma8ppw3nhx5r4ap8clazz0dps7rv5u9xde7p
address has a
balance of 30m DJT on the Method Chain. 20m should be unlocked and 10m locked and
stakeable.
_10curl --location --request POST '127.0.0.1:9650/ext/bc/P' \_10--header 'Content-Type: application/json' \_10--data-raw '{_10 "jsonrpc":"2.0",_10 "id" :1,_10 "method" :"platform.getBalance",_10 "params" :{_10 "address":"P-custom18jma8ppw3nhx5r4ap8clazz0dps7rv5u9xde7p"_10 }_10}'
You can visit Dijets Wallet, add a custom network and the prefunded private key from above, to check the balance of all three of the Value, Utility & Method Chains all at once.