Cosmos SDK - Secret
Publish on chain using secretjs
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 with testnet Scrt. To connect to the testnet you can use this website
You can access the code of this walkthrough on Gitlab:
Contract deployment
Clone the client contract repo.
This Secret contract serves as a client to our Reclaim contract. It takes Reclaim's contract address and code hash, handles proofs, and verifies them.
Add your wallet information.
As stated in the README, add your wallet credentials to your node/.env
as specified in node/.env.example
.
Deploy and verify a proof.
Give the node/verify.js file a quick read, 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 node/verify.js
, 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 and code hash, 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.
Setup your React codebase.
We will continue building on the reclaim react client, new lines are highlighted below.
Create a new folder (secretJs).
Structure the folder as per the following, these are configs to call Reclaim on Secret.
Copy this to SecretjsContext.js.
By default, the values below are for Secret's testnet, uncomment for mainnet.
Copy this to SecretjsFunctions.js.
Replace with your contract address and code hash. 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 Secret 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.