An easy tutorial for developing with the Cardano blockchain. Create a wallet. Send and receive ADA.
-
Clone the Plutus project to setup the code.
git clone https://github.com/IntersectMBO/plutus-tx-template.git
-
Create a new directory
off-chain
and add required node js modules.mkdir off-chain cd off-chain npm add @meshsdk/core npm add cbor
-
Create an account on BlockFrost to avoid needing to run your own local blockchain node.
-
Create a BlockFrost project named hello-world on the Cardano preview network.
-
Create a file
.env
with the contents:BlockFrostProjectId=<BLOCKFROST_PROJECT_ID> SenderSecretPathName=keys/seller2.skey RecipientAddress=<RECIPIENT_ADDRESS>
Obtain the Project ID from your BlockFrost dashboard. Create a seller2.skey by running
generate.py
. -
Create a local wallet by running the file generate-keys.mjs.
node generate-keys.mjs
You should see output similar to the following:
Generated key: <WALLET_SECRET_KEY> generate-keys.mjs:8 Wallet instance created: MeshWallet {_wallet: EmbeddedWallet, _accountIndex: 0, _keyIndex: 0, _fetcher: undefined, _submitter: undefined, …} generate-keys.mjs:12 Unused addresses: (1) ['<WALLET_ADDRESS>'] generate-keys.mjs:16 Generated address: addr_test1<WALLET_ADDRESS> generate-keys.mjs:25 Public key hash: <WALLET_PUBLIC_KEY> generate-keys.mjs:29 Creating seller. generate-keys.mjs:42 Creating bidder1. generate-keys.mjs:42 Creating bidder2.
-
Get free ADA for the new wallet by using the Cardano Faucet on Preview Testnet. Enter the seller's Address from
keys/seller.addr
(for example,addr_test1<WALLET_ADDRESS>
).You should see output similar to the following:
Success Your transaction has been successful and test funds have been sent to addr_test1<WALLET_ADDRESS>. Please verify the following transaction hash: <TRANSACTION_HASH>
-
Verify the transaction for receiving ADA at Cardanoscan. Paste in the transaction hash and click on the UTXO tab to see the ADA transferred to the wallet. Return tokens after use to
addr_test1vqeux7xwusdju9dvsj8h7mca9aup2k439kfmwy773xxc2hcu7zy99
. -
Send ADA to another wallet by using send-lovelace.mjs. Note, amount is in lovelace, where 1 ADA = 1,000,000 lovelace.
node send-lovelace.mjs <from_secret> <to_address> <amount>
You should see output similar to the following, which may also be confirmed on Cardanoscan:
Ada sent. Recipient: addr_test<TO_ADDRESS>, Tx hash: <TRANSACTION_HASH>
-
Verify the transaction for sending ADA at Cardanoscan. Paste in the transaction hash and click on the UTXO tab to see the ADA transferred to the wallet. Return tokens after use to
addr_test1vqeux7xwusdju9dvsj8h7mca9aup2k439kfmwy773xxc2hcu7zy99
. -
Check the balance of any of the generated wallets using balance.mjs:
node balance.mjs addr_test1<WALLET_ADDRESS>
You should see output similar to the following:
Assets: {lovelace: '1000000'} Balance for address addr_test<WALLET_ADDRESS>: 1 ADA
-
Confirm the wallet balance at Cardanoscan by entering the wallet address (instead of a transaction hash).
MIT
Kory Becker http://primaryobjects.com