Bounty hunting is a great way to get to know a software platform deeply, connect with the development team, and make some money in the process. For the recent Agoric “Cosmos Cross Chain Contract Challenge” bounty, I set out to show how to use a smart contract to send interchain account messages. Agoric is a platform for composable and reusable smart contracts. Once anyone contributes a component, it’s available ecosystem-wide for adoption. Now that I’ve completed my contract, devs can utilize the Interaccounts Agoric smart contract to interact with other chains from Agoric.

If Interchain Accounts are unfamiliar, check out Charly Fei’s summary from earlier this year. Key quote:

“As a next step in the evolution of cross-chain interoperability, Interchain Accounts enable native composability in cross-chain transactions, which will allow for chains to not only exchange data, but write state — instead of requiring an end user to move across various interfaces as an asset moves.”

Journey Into Crypto

As a Web3 dev, I love being able to build smart contracts in JavaScript. I’ve used JavaScript heavily for six years, so working on Agoric was easy for me to pick up. Agoric’s focus on hardened JavaScript enables me to put to use my experience in NodeJS, rather than having to learn yet another language. Hardened JavaScript lets you run third-party code securely thanks to its library of object-capability components. That’s in contrast with smart contract languages that were created much more recently. I’ve found that Rust, Solidity, and even Golang, for example, can involve larger code bases and more complicated developer tooling and, thus, are more expensive to work in. 

I first stumbled on Agoric just by Googling blockchains that support JavaScript two years ago. I’ve been following Agoric ever since. I have a lot of background in finance, working for various funds, building equity research software, automated trading bots, market making bots, quantamental investing strategies, and things like that. I was working for a fund during college and then out of college I went full time into my development agency: 

  • building automated trading strategies
  • equity research software
  • fintech software

I got started with crypto around 2019, initially working in Solana. Along the way, I determined that I don’t believe in the longevity of bridging — instead, I’ve come to believe in cross-chain messaging like Axelar does, which is how I stumbled on IBC and eventually got engulfed in Cosmos. Since then I’ve been contributing non-stop to the Cosmos ecosystems, like interchain querying, Defund, Agoric, and the Osmosis automated market maker.

Getting Going with Agoric

It took me about one to two months to feel comfortable developing on Agoric. I picked it up quickly because I was able to run through the Cosmos SDK code along with the Agoric SDK code. The Agoric team has been a big help along the way. In fact, I learned about this bounty because I had started working on an Agoric smart contract for ICS-27 interchain accounts to support my Calypso dapp, also built on Agoric. In the process, I got to know Michael FIG, an Agoric engineer, and Jeet Raut, who works on partner programs at Agoric. They told me there was a bounty for what I was working on, and invited me to do it.

Calypso UX under development

The biggest challenge I faced during the bounty was learning how the Agoric SDK differs from Cosmos’s SDK. With the Agoric SDK, you have the JS layer on the top, and underneath it is the Golang Cosmos SDK-based chain. I was familiar with Cosmos SDK-based chain and how it works with ICA, because that’s what I usually build with. But for the bounty, I needed a specific module to be implemented within Agoric. The main difference is that Agoric doesn’t implement certain modules on the Golang side. Instead, it’s on the chain side. Also, there were issues with port names, which were manually specified in the SDK and needed to be dynamic. So in order to make it work I had to do some Agoric SDK work.

There was one other complication worth mentioning: ICA technically only supports IBC Go version three, while Agoric uses IBC Go version two. So I had to make it work with version two, at least for now, until the Agoric upgrade to IBC-Go three happens.

It took a few weeks of part time effort. Beyond the Cosmos and Agoric SDKs, I am familiar with Node.js, Julia, Golang, Python, Rust, and C. For front end development, I am familiar with Vue.js, React, and Svelte. I usually work in VS Code and sometimes I use Atom, too.

The Bounty Core Code

Below is the key code I developed for sending ICA transactions, ICAs being interchain accounts on Cosmos. Note that first you have to deploy the contract and set up ICA accounts on the host chain. 

raw_msg = {

    "from_address":"cosmos15ccshhmp0gsx29qpqq6g4zmltnnvgmyu9ueuadh9y2nc5zj0szls5gtddz",

    "to_address":"cosmos10h9stc5v6ntgeygf5xf945njqq5h32r53uquvw",

    "amount": [

        {

            "denom": "stake",

            "amount": "1000"

        }

    ]

}

// You must use protobuf to encode the raw msg into a uint8array you use for the value input. Look at the test contract to see an example with MsgSend

msg =  E(instance.publicFacet).makeMsg({type: "/cosmos.bank.v1beta1.MsgSend", value: proto_msg_uint8array})

packet = E(instance.publicFacet).makeICAPacket([msg]);

connection.send(JSON.stringify(packet))

Here’s a two-part video of the contract in action:

What’s Next for my Dapp

Check out my GitHub to see it in detail. For more of my work, visit my dev agency, Pital, and check out Calypso, which is an Agoric dapp that we’re releasing. Follow us on Twitter to stay updated for our official release. The Calypso dapp is the reason I was doing the work that led me to this bounty project in the first place.

For devs looking to get started on Agoric, visit agoric.com/develop, agoric.com/github, and agoric.com/discord.