-
Notifications
You must be signed in to change notification settings - Fork 14
cli
pegnetd
comes with a cli to interact with the daemon. The binary pegnetd
could be a variety of names depending on your system. For the purpose of this guide, we will be using pegnetd
as the executable downloaded from the releases page. If you want to be able to copy paste these commands, you can create a simple alias:
echo "Aliasing 'pegnetd' to the executable. Replace 'pegnetd-linux-amd64' with the executable you downloaded!"
alias pegnetd=./pegnetd-linux-amd64
If you placed your binary in your pegnetd
application folder, we need to change our directory there before running any commands.
cd $HOME/.pegnetd
To see all the commands, you can run pegnetd help
for the up to date list of commands provided by the cli. Each command can be further inspected by pegnetd help <command>
, such as pegnetd help balances
. When doing a help, the command arguments are provided as well as an example and description.
Before running any commands, we want to ensure our pegnetd
is synced up to the network. You can look for the network's height at https://explorer.factom.com. The status will give us 2 heights. The syncheight
is the height pegnetd
is synced too, and factomheight
is the height the factomd that pegnetd
is communicating with is synced too. We want these numbers to match the explorer's latest height.
Note: syncheight
will be off by 1 for the first minute of each block. This is normal behavior
$ pegnetd status
{"syncheight":214296,"factomheight":214296}
This command will list all the pegnet balances for a given factoid address.
$ pegnetd balances FA2CEc2JSkhuckEXy42K111MvM9bycUDkbrrHjd9bNkBfvPBSGKd
{"PEG":"0","pADA":"0","pBNB":"0","pBRL":"0","pCAD":"0","pCHF":"0","pCNY":"0","pDASH":"0","pDCR":"0","pETH":"0","pEUR":"0","pFCT":"0","pGBP":"0","pHKD":"0","pINR":"0","pJPY":"0","pKRW":"0","pLTC":"0","pMXN":"0","pPHP":"0","pRVN":"0","pSGD":"0","pUSD":"0","pXAG":"0","pXAU":"0","pXBC":"0","pXBT":"0","pXLM":"0","pXMR":"0","pZEC":"0"}
Often we only care about the balances of a single asset owned by a factoid address. We can query for the balance of 1 asset like so:
$ pegnetd balance PEG FA2CEc2JSkhuckEXy42K111MvM9bycUDkbrrHjd9bNkBfvPBSGKd
0 PEG
Burn allows you to convert FCT -> pFCT and get into the pegnet ecosystem. To run the command, factom-walletd is required to have the FCT address, and a factomd must be accessible. The command generates a factoid transaction. The amount field is in FCT.
$ pegnetd burn FA2CEc2JSkhuckEXy42K111MvM9bycUDkbrrHjd9bNkBfvPBSGKd 5
Successfully submitted the transaction
Transaction ID: ca30aea558af2a7d3d5fe74039ecc158d7ad2bcc9ebbcf9c42f30b257381cde7
Once you have a balance, you can begin making transactions. A transaction is when you are sending a single type of asset from 1 address to another. To make a tx requires 1 EC. If you are unsure of how to obtain EC, you can read this. To send this example tx, you would need to own the EC address EC3eX8VxGH64Xv3NFd9g4Y7PxSMnH3EGz5jQQrrQS8VZGnv4JY2K
and FA2jK2HcLnRdS94dEcU27rF3meoJfpUcZPSinpb7AwQvPRY6RL1Q
in factom-walletd
, and have enough PEG and 1 EC for the transaction.
$ pegnetd newtx EC3eX8VxGH64Xv3NFd9g4Y7PxSMnH3EGz5jQQrrQS8VZGnv4JY2K FA2jK2HcLnRdS94dEcU27rF3meoJfpUcZPSinpb7AwQvPRY6RL1Q PEG 200 FA32xV6SoPBSbAZAVyuiHWwyoMYhnSyMmAHZfK29H8dx7bJXFLja
transaction sent:
EntryHash: 65bdda388e7957d038fe01696f67125230bae750506866aa801894ecac3c86bf
Commit: e77eed093cc24fe961210e6f892f403c19467f3e2b6e1b9d81484dad9d1d30b6
The tx will be applied when the block is complete. You can use a blockchain explorer to confirm your entryhash has made it into the blockchain. Wait at least 10minutes before considering redoing the transaction.
A conversion converts 1 asset type into another using the conversion rates determined by the miners on the network. The resulting asset is still owned by the same address, meaning you cannot convert funds to a new address, only within a single address. To convert 100 PEG into pUSD, you will need to own EC3eX8VxGH64Xv3NFd9g4Y7PxSMnH3EGz5jQQrrQS8VZGnv4JY2K
and FA2jK2HcLnRdS94dEcU27rF3meoJfpUcZPSinpb7AwQvPRY6RL1Q
in factom-walletd
and have enough PEG and 1 EC to do the conversion.
NOTE: If you make a conversion at block height 10, the conversion is not applied until height 11, using the rates in height 11. This means the conversion rates used are in the future, and unknown at the time you make the conversion. Conversions can take up to 20mins to be processed.
$ pegnetd newcvt EC3eX8VxGH64Xv3NFd9g4Y7PxSMnH3EGz5jQQrrQS8VZGnv4JY2K FA2jK2HcLnRdS94dEcU27rF3meoJfpUcZPSinpb7AwQvPRY6RL1Q PEG 100 pUSD
conversion sent:
EntryHash: 14f0033bb54b91258ce58a4b6325c5ec251af3805c48fbede1f8ee29d78bd8e3
Commit: 8095e0713dc51c5c30ae074f2fafa8af89d447f3f9ad9bb43ba63f067341df19
After making a transaction, you will want to confirm it was a valid transaction. If you are given a pegnet txid, you can use the get tx
cli command to confirm a payment. A Factom blockchain explorer is NOT sufficient. Just because a tx was recorded on chain, does not mean it is valid and executed. The explorer must specifically support pegnet to properly indicate if a tx was executed. If the get tx
command returns transaction data, that means it was executed.
$ pegnetd get tx 00-64bdda388e7957d038fe01696f67125230bae750506866aa801894ecac3c86bf
{"actions":[{"executed":214297,"fromaddress":"FA28MV2VvvsdjjgXoHwsadtMWqM5mt7bZU3hMjLuDLLN1DBhK48g","fromamount":1,"fromasset":"PEG","hash":"64bdda388e7957d038fe01696f67125230bae750506866aa801894ecac3c86bf","height":214297,"outputs":[{"address":"FA3JJ9pFqbuawkR1U8pfp2e4jYET6odV3vruQAHydHVj2uLcu7hF","amount":1}],"timestamp":"2019-10-14T11:44:00-05:00","txaction":1,"txid":"0-64bdda388e7957d038fe01696f67125230bae750506866aa801894ecac3c86bf","txindex":0}],"count":1,"nextoffset":0}
An invalid transaction will return:
Failed to make RPC request
Details:
jsonrpc2.Error{Code:-32803, Message:"Transaction Not Found", Data:"no matching tx-id was found"}
This allows you to grab all transactions for a height, hash, or address.
$ pegnetd get txs FA28MV2VvvsdjjgXoHwsadtMWqM5mt7bZU3hMjLuDLLN1DBhK48g
{"actions":[{"executed":213869,"fromaddress":"FA2mPQpBhr7f9XtXMVhsYQjNzsMGv1sqk2dTZp1NyTBuCaR6BjLM","fromamount":209846358175,"fromasset":"PEG","hash":"8cc6bfd35330f0ae8e71a425a7cd50aec07780ea0f462b345addf0190c1e8803","height":213869,"outputs":[{"address":"FA2Z4BSZzSUcnLUsCrPBjXNMKUQaXFGtY3SdFYYuMbzsBkMtcHBX","amount":209846358175}],"timestamp":"2019-10-11T12:17:00-05:00","txaction":1,"txid":"0-8cc6bfd35330f0ae8e71a425a7cd50aec07780ea0f462b345addf0190c1e8803","txindex":0},
...
],"count":3,"nextoffset":0}
Multiple transactions are returned. You can also filter by type by providing a combination of --burn
, --coin,
--cvt, and
--tran`. Like to see only burns:
$ pegnetd get txs FA28MV2VvvsdjjgXoHwsadtMWqM5mt7bZU3hMjLuDLLN1DBhK48g --burn
{"actions":[{"executed":207480,"fromaddress":"FA28MV2VvvsdjjgXoHwsadtMWqM5mt7bZU3hMjLuDLLN1DBhK48g","fromamount":100000000,"fromasset":"FCT","hash":"e8679cb79611217bbae3562c5092a29ac97eb7624dc20d1ad1e50913af85263d","height":207480,"timestamp":"2019-08-27T16:26:20-05:00","toamount":100000000,"toasset":"pFCT","txaction":4,"txid":"0-e8679cb79611217bbae3562c5092a29ac97eb7624dc20d1ad1e50913af85263d","txindex":0},{"executed":212576,"fromaddress":"FA28MV2VvvsdjjgXoHwsadtMWqM5mt7bZU3hMjLuDLLN1DBhK48g","fromamount":100000000,"fromasset":"FCT","hash":"fd69a19dc88295b0165479b41a992291cc0fd89b28fcb3f956bbadccb884b607","height":212576,"timestamp":"2019-10-02T12:22:51-05:00","toamount":100000000,"toasset":"pFCT","txaction":4,"txid":"0-fd69a19dc88295b0165479b41a992291cc0fd89b28fcb3f956bbadccb884b607","txindex":0}],"count":2,"nextoffset":0}
You can query the USD rates of each asset for any recorded block with get rates
. You can never query the rates for a pending or future block, as those rates have not yet been determined.
$ pegnetd get rates 214297
{"PEG":"0.00310593","pADA":"0.04136114","pBNB":"18.13408096","pBRL":"0.24215995","pCAD":"0.75588646","pCHF":"1.0029034","pCNY":"0.14149078","pDASH":"70.73233179","pDCR":"16.02819861","pETH":"183.52891717","pEUR":"1.10278143","pFCT":"3.57307797","pGBP":"1.25628772","pHKD":"0.12747476","pINR":"0.01404346","pJPY":"0.00922649","pKRW":"0.00084468","pLTC":"56.71646036","pMXN":"0.05192511","pPHP":"0.01939093","pRVN":"0.03557481","pSGD":"0.73062243","pUSD":"1","pXAG":"17.63606222","pXAU":"1492.53731343","pXBC":"226.52878574","pXBT":"8323.63169694","pXLM":"0.06346104","pXMR":"52.93867928","pZEC":"37.06211789"}
To get the global richlist in terms of pUSD
pegnetd richlist
To get the richlist of an asset
pegnetd richlist pXBT
If you are curious what the total amount of each asset exists on the network, you can use the issuance
command.
$ pegnetd issuance
{"sync-status":{"syncheight":214297,"factomheight":214297},"issuance":{"PEG":"50627421.95022136","pADA":"91.7474151","pBNB":"0.23964155","pBRL":"15.53769559","pCAD":"5.05757599","pCHF":"20.31773352","pCNY":"27.16169709","pDASH":"0.05317841","pDCR":"0.21694146","pETH":"18.38430641","pEUR":"12.85311327","pFCT":"38463.0188198","pGBP":"3.08496745","pHKD":"29.80001159","pINR":"269.81732013","pJPY":"406.94137315","pKRW":"4547.20374337","pLTC":"0.06640888","pMXN":"74.28080364","pPHP":"197.17349003","pRVN":"143911.45402388","pSGD":"5.24774284","pUSD":"3689.1585855","pXAG":"100.29803207","pXAU":"1.46856894","pXBC":"0.01623103","pXBT":"0.41840524","pXLM":"61.58039443","pXMR":"0.06690407","pZEC":"0.10101202"}}