The Encouragement Dapp is the simplest Agoric Dapp. It demonstrates the three important parts of a dapp and how they should be connected:
- the browser UI (the frontend)
- the API server (the backend)
- the on-chain contract
This dapp starts a local blockchain on your computer, and deploys a basic contract to that blockchain. It does not currently deploy or connect to the Agoric testnet.
This particular dapp UI is written in vanilla JS for simplicity (as opposed to using a framework).
The Encouragement Dapp:
-
Subscribes to contract notifications via the API server
-
Accesses your Agoric wallet, and
-
At the user's request, either:
- requests some free encouragement, or
- proposes (via the user's wallet and Zoe) exchanging a Tip for some Encouragement (the tip is not yet sent to the Zoe contract, but you will still get some encouragement.)
To learn more about how to build Agoric Dapps, please see the Dapp Guide.
Here's the interface:
and after we click the "Encourage Me!" button:
Things we need to fix are listed in the Github issues for this repository.
For the hackathon: try the following at the REPL:
TODO: /ibc-hop/$MYCONNNAME/ibc-port/$THEIRPORT
c = home.ibcport[1]~.connect('/ibc-port/portbvmnfb',
{ onReceive(c, bytes) { console.log("Encourager says: ", bytes); } });
c~.send('hello!');
c~.close();
How to run two solo vats for the same chain:
cd ~/agoric-sdk/packages/cosmic-swingset
make NUM_SOLOS=2 scenario2-setup scenario2-run-chain
make scenario2-run-client BASE_PORT=8000
make scenario2-run-client BASE_PORT=8001
How to run using the relayer!
./scripts/nchainz init ibc0=agoric ibc1=agoric ibc0:ibc1
Answer 'yes' to overrite, 'no' to run the relayer
./scripts/nchainz run
Deploy your contract. It will go to the ag-solo at port 8000.
In the REPL for http://localhost:8001:
c = E(home.ibcport[2]).connect('/ibc-hop/ibczerolink/ibc-port/portbvmnfb/ordered/demo1',
{ onReceive(c, bytes) { console.log("Encourager says: ", bytes); },
infoMessage(...msg) { console.log("IBC Connection Info: ", ...msg); } })
Copy the config to ~/.relayer/config/config.yaml
, especailly note the port names.
./scripts/nchainz relay