- Cosmoverse 2022 (Medellin, Colombia)
- Gateway to Cosmos 2022 (Prague, Czech Republic) recording
- It's likely that
AssetKind.SETandAssetKind.COPY_SETwill be deprecated in favor ofAssetKind.COPY_BAG. We have thus updatedcontract-0to show howCOPY_BAGworks and also used it in the 'NFT' example. - In recent builds of Agoric SDK, the ag-solo wallet is deprecated, see issue #6189 . To run these exercises, please make sure you are using Agoric SDK version by executing
git checkout 3482e0d98748c9b7995c93cbef9a06b0ec0fbea8in theagoric-sdkdirectory
Without the pre-requisites you won't be able to complete the exercises.
First make sure you have node.js v16 and yarn installed on your system.
Please check:
node --versionreturnsv16.YY.ZZorv18.YY.ZZthe minor and patch version are not importantyarn --versionreturns a version like1.22.ZZ
Then:
- Install the Agoric SDK
git clone https://github.com/Agoric/agoric-sdk - Checkout beta
cd agoric-sdk - Install
yarn && yarn build - Install the
agoricscript by runningyarn link-cli
Test whether you can run agoric --version and get a version number like 0.15.0 back. If yes, you are all set.
git clone https://github.com/rbflabs/intro-agoric-smart-contracts.git agoric-workshopcd agoric-workshop && agoric install
Agoric install performs the necessary installation steps so we can run our examples.
Load up the workshop presentation, which will kick off the workshop. We will explain why Agoric has a strong value proposition and why I think writing smart contracts on Agoric is safer from the get-go.
Each exercise has the working script and the solutions script. It's benefical to type out the exercises but the solutions are there for reference whenever needed.
We recommend running a terminal inside VS Code and having Ava watching your files and re-running tests to obtain immediate feedback.
Exercise focus: ERTP
New concepts: Issuers, Brands, Amounts, Payments, Purses, test-driven contract development
Synopsis: In the contract-0 directory, we focus on test driven development (there is no contract to build) to learn about issuers, amounts, brands, mints, payments and purses. These are the Lego blocks for creating, describing and transferring value.
How to start, run the following commands:
cd contract-0yarnyarn ava test/test-contract.js -w
Do this either inside your system terminal or inside your visual code terminal.
Exercise focus: ERTP Zoe Zoe Contract Facet (zcf) Remotable objects
New concepts: Invitations, Seats, Offers, (creator, public) Facets
Synopsis: contract-1 is is our first contract that has real functionality - minting Moolas (imaginary fungible asset). We show how to define regular functions that can be called on the contract. Then we focus on the contract interaction lifecycle: invitation -> offer -> seat -> offer result. We then extract a payment from the offer result and deposit it in a purse.
How to start:
cd contract-1yarnyarn ava test/test-contract.js -w
Exercise focus: Zoe
New concepts: contract terms, IssuerKeywordRecord
Synopsis: contract-2 allows the creator to mint NFTs in exchange for Moolas. We show how to setup a contract to know about issuers. The contract we will write here accepts Moola and mints NFTs using an issuer Awesomez that it alone holds. We then run through the offer lifecycle and finally we introduce a bug into the contract and show that Zoe steps in to protect the user -- this offer safety in action.
How to start:
cd contract-2yarnyarn ava test/test-contract.js -w
react-ui is a dApp that binds together contract-1 and contract-2 so that the former mints Moola tokens which are accepted by the latter.
To begin working move to the root of the repository and:
agoric start --resetagoric deploy contract-1/deploy.jsagoric deploy contract-2/deploy.jsagoric opencd react-uiyarnyarn start
After the above process you should have two tabs open in your browser with the Agoric wallet and with the React application. Enter a value into the first text field and mint some Moola. When you have over 100 Moola, you can try to mint an NFT.