In this tutorial, we will do the following:
- Create an App Wallet
- Add the App Wallet Details to the Chain SDK
- Create a new Asset in the App Wallet called "Gold Stars"
- Create Buckets in the App Wallet for the Treasury and two users - Devon and Ryan
- Issue 10 Gold Stars into the Treasury
- Transfer 1 Gold Star to Devon and 2 Gold Stars to Ryan from the Treasury
To create an App Wallet, we visit the Chain Dashboard and click the "Create Development Wallet" button.
We choose a 2-of-2 multi-signature configuration with 1 Chain Co-signer Key and choose to generate our Key.
We then save the Wallet details for use on our webserver when issuing and trasnferring assets.
require 'chain-wallets'
c = ChainWallets::Client.new(
token_id: '7af82266416257dada0980dcb641fbd5',
token_secret: '30ab0430c4f2ed6445a63c96441191d9'
)
c.keystore.add(ChainWallets::XPrvKey.new('xprv...'))
We visit the Dashboard and click on our newly created App Wallet labeled "Gold Stars".
We then click the "Assets" tab in the top right and click the "Create Asset" button.
We create a new immutable asset, defining only the name in the asset definition and providing no definition URL.
We save the newly created Asset ID for use in the SDK when issuing and transferring units of the Asset.
We then click the "Buckets" tab in the top right of the Wallet view and click the "Create Bucket" button.
When save the newly created Bucket ID as the Treasury for use in the SDK when issuing and transferring units of our "Gold Stars" Asset.
When repeat this process for Devon and Ryan's Buckets and save the Bucket IDs.
c.issue_asset('AawTzyEy8dnbKYicVeAb1GCq6f8yWeE9Rt',[{
bucket_id: '0c676fd5-6eb9-42cd-b234-524160fff514', #Treasury bucket id
amount: 100
}])
c.transfer_asset(
inputs: [{
asset_id: 'AawTzyEy8dnbKYicVeAb1GCq6f8yWeE9Rt',
bucket_id: '0c676fd5-6eb9-42cd-b234-524160fff514', #Treasury bucket id
amount: 3,
min_confirmations: 0
}],
outputs: [
{
asset_id: 'AawTzyEy8dnbKYicVeAb1GCq6f8yWeE9Rt',
bucket_id: '9d2ff7e1-acbc-4c26-b72d-a129108135d3', #Ryan's bucket id
amount: 2
},
{
asset_id: 'AawTzyEy8dnbKYicVeAb1GCq6f8yWeE9Rt',
bucket_id: '449f7759-ef7b-42e1-9b0f-3f27b4fe2e40', #Devon's bucket id
amount: 1
}
]
)
Hi Ryan, thanks for documenting this. Can you provide more detail on step 2--adding to Chain SDK.
And where you add 5 and 6. I'm trying to test this out, but I'm not sure how to execute this via a webserver. Are there any specifics for the server that you use or what type of files you have to embed them in?
Trying to do some testing...simulation to see how this works.
Thanks