Cosmos SDK - Archway
Publish on chain using CosmWasm
Pre-requisite
At this stage, we assume that you followed the steps at ReactJs.
We will be using Keplr as a wallet to interact with the frontend interface. Make sure that you have it installed and funded via Archway-Testnet Faucet Channel.
Also, we use Wamskit for compiling and deploying the cosmwasm contracts.
It is automatically installed when installing npm modules.
You can access the code of this walkthrough on Gitlab:
Contract deployment
Clone the client contract repo.
This Archway contract serves as a client to our Reclaim contract. It takes Reclaim's contract address, handles proofs, and verifies them.
Add your wallet information.
As stated in the README, add your wallet credentials to your wasmkit.config.js
as specified in wasmkit.config.js.example
.
Deploy and verify a proof.
Take a look at wasmkit.config.js
and all.ts
, make sure that you have the correct RPCs and contract addresses.
If you want to deploy to mainnet, search for the Uncomment for mainnet
comment.
By running wasmkit run scripts/all.ts
, you can upload the contract, instantiate it, and verify a Reclaim proof on it.
Run the script and take a note of your contract address, we will be using them later.
Here is an example of how your output should look like:
React client development
Bootstrap project and install packages.
Add the following to project dependency(packages.json) and install modules.
Setup your React codebase.
We will continue building on the reclaim react client, new lines are highlighted below.
Create a new folder (utilities).
Structure the folder as per the following, these are configs to call Reclaim on Archway.
Copy this to ArchwayContext.js.
By default, the values below are for ArchwayContext's testnet, uncomment for mainnet.
Copy this to ArchwayFunctions.js.
Replace with your contract address. You can leave values as are if you did not do the deployment step, make sure to uncomment values for mainnet.
Wrap the App with the specified Archway context (index.js).
Create a VerifyProof component.
Include the VerifyProof() function.
Create a ConnectButton component.
Add a button and placeholder for connecting.
Bringing it all together (App.js).
We will submit the proof on chain once we get the success
callback. New lines are highlighted.
Submitting the proof
After requesting a proof from Reclaim and performing the verification on your end, a verify proof button will appear on the screen. Make sure your Keplr is connected, click the button, a wallet pop-up will show prompting you to submit.
Now your proof will get approved on-chain, here is the sample transaction from the screenshot above.