What unique relationship establishes the two contracts on the source chain and the target chain?

I now want to deploy the contracts on my source chain and target chain separately. Later, I encountered an issue: how are these two contracts connected? For example, if today I deploy the contract on the source chain on Computer A, and tomorrow I deploy the contract on the target chain on Computer B, how does the contract on the source chain locate the contract I deployed on the target chain when I call the contract on the source chain to send a packet?


Hey @Jayce

Will share this again for those who did not catch your post on Discord.

Polymer uses IBC heavily under the hood so I advise everyone to check out our docs that give a primer on IBC: IBC essentials | Polymer Developer Docs

Essentially the contracts you deploy are “connected” by getting a channel-ID assigned that forms an IBC channel. You can think of an IBC channel as an application specific “lane” on an IBC connection between two chains / rollups.

A channel is closely related to the concept of a port. There’s a number of functions for a port as explained in the doc, but largely it authenticates the contracts that are allowed to send packets over a channel (which is a pair of channel-Ids).

Extra background

Some points that are important to understand:

  • A “channel” under the hood is a pair of channelEnd objects stored for each party (if we are connecting Optimism and Base, there would be channel-x corresponding to Optimism and channel-y corresponding to Base).
  • When using Polymer and “virtual IBC”, Polymer stores all relevant IBC state, including these channelEnds.
  • The format of the portID makes it very clear which contract is allowed to send packets over it. E.g. port ID for contract 0x3F30d98fd4776bA016E983d224dB2B19e75a460D would be polyibc.base-sim.3F30d98fd4776bA016E983d224dB2B19e75a460D which takes a port prefix, a client identifier (here the sim-client on Base sepolia) and the contract address (minus the ‘0x’ hex prefix)

Hope that helps you going. Once more, Polymer uses IBC extensively so read carefully through the docs to understand what’s going on and feel free to ask more clarifying questions!

1 Like

Also take a look at https://www.ibcprotocol.dev/ and follow https://twitter.com/IBCProtocol on twitter

They are releasing some great educational content frequently!

Thank you for your explanation, I understand.

1 Like