Skip to main content

Deploy Your First Cross-Chain Contract

Get started with Pylon by deploying a contract on one of our demo appchains and read from their settlement layer.

Prerequisites

Step 1: Create Your Project

Step 2: Configure Your Network

Add to your foundry.toml:
Available Networks:

Step 3: Make a Direct Cross-Chain Call

Let’s start by understanding how cross-chain calls work. Pylon provides a Port Contract that reads from the settlement layer. Make a direct call to read WETH name from the settlement layer:
What happened:
  1. Called the SettlementPort contract at 0x0000000000000000000000000000000000000042
  2. Told it to call name() on WETH (0x4200000000000000000000000000000000000006)
  3. The coordinator detected the cross-chain call, forwarded it to the settlement layer, and returned the result synchronously
  4. The result is encoded as bytes
Since the return type for the settlement contract being called is known, just specify the return type and it will automatically decode the result:
This demonstrates synchronous composability - you can read from the settlement layer as if it were on the same chain.

Step 4: Create Forwarding Proxy (Better Developer Experience)

Making raw readSettlement calls works, but it’s verbose. We can create a forwarding proxy that makes settlement layer contracts callable using standard interfaces like ERC20. Create src/SettlementForwardingProxy.sol:
Create src/ISettlementReader.sol:
Deploy the proxy (replace with your actual settlement port address):
Save the proxy address - you’ll use it in the next step. What this proxy does:
  • Constructor takes two addresses: the SettlementPort and a target contract (in this case WETH)
  • fallback() captures any function call and forwards it to readSettlement()
  • Returns the result as if the target contract were local
  • This lets you call settlement layer contracts using standard interfaces

Step 5: Create a Contract That Uses the Proxy

Now let’s create a contract that demonstrates using the proxy with standard interfaces: Create src/ProxyCaller.sol:
How this works:
  • ProxyCaller calls standard ERC20 functions on the PROXY address
  • The proxy’s fallback() forwards these calls to SettlementPort
  • SettlementPort reads from the settlement layer synchronously via priming transactions
  • Results return as if WETH were deployed on your appchain

Step 6: Deploy Contracts

Deploy the ProxyCaller contract:
Save the ProxyCaller address.

Step 7: Test Your Cross-Chain Calls

Test getting WETH name, symbol, and decimals via the proxy. These calls demonstrate how you can interact with settlement layer contracts using standard interfaces, just like they were on the same chain.

What This Demonstrates

  1. Direct Pattern (Step 3): Made raw readSettlement calls to SettlementPort, showing the foundation of cross-chain reads
  2. Proxy Pattern (Step 4-5): Created a forwarding proxy that enables standard interface calls to settlement layer contracts from your appchain contracts
  3. Developer Experience: Now you can call settlement layer contracts using familiar Solidity syntax and interfaces

How Cross-Chain Calls Flow Through Pylon

How Cross-Chain Calls Flow Through Pylon The key insight is that Pylon’s coordinator detects these cross-chain calls, forwards them to the settlement layer, captures the results, and makes them available synchronously through the Port Contract. This is synchronous composability in action.

Next Steps