Documentation Index
Fetch the complete documentation index at: https://docs.goldsky.com/llms.txt
Use this file to discover all available pages before exploring further.
Compose comes with built-in chain support powered by our own “Edge RPC” product for reliable, low-latency RPC access. See the full list of networks available out of the box on the Edge RPC supported networks page. Need a chain that isn’t listed? Contact us at support@goldsky.com and we can look into adding support.
You can access any built-in chain with evm.chains.<chainName> — the chain keys match the exports from viem/chains (for example, Ethereum mainnet is evm.chains.mainnet, not evm.chains.ethereum). Compose also supports custom chain configurations for any EVM network not covered by Edge RPC. See Wallets and Smart Contracts for more details on how chains are used.
Using built-in chains
This is the easiest and most reliable option for most scenarios.
import { TaskContext } from "compose";
export async function main({ evm }: TaskContext) {
// the "chains" object is typed and holds all our natively supported chains
// native chains are pre-configured to use Goldsky's Edge RPC
console.log(evm.chains.base);
console.log(evm.chains.mainnet); // Ethereum mainnet
}
Using custom chains
To use a custom chain you just need to create an object that fulfills our Chain interface.
import { TaskContext, Chain } from "compose";
export async function main({ evm, env }: TaskContext) {
// custom chain spec
const myCustomChain: Chain = {
id: 480,
name: "My Custom Chain",
testnet: false,
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
rpcUrls: {
default: { http: [`https://mycustomchain-mainnet.g.alchemy.com/v2/${env.MY_CUSTOM_CHAIN_API}`] },
public: { http: ["https://mycustomchain-mainnet.g.alchemy.com/public"] },
},
blockExplorers: {
default: { name: "myCustomChainScan", url: "https://myCustomChainScan.org" },
},
};
// you can now use the myCustomChain const anywhere you'd use a built-in chain (see Wallets and Smart Contracts for details)
console.log(myCustomChain);
}
The Chain type is available from the TaskContext interface. Here it is for reference:
export type Chain = {
id: number;
name: string;
testnet: boolean;
nativeCurrency: {
name: string;
symbol: string;
decimals: number;
};
rpcUrls: {
public: { http: string[] };
default: { http: string[] };
};
blockExplorers: {
default: { name: string; url: string };
};
contracts?: Record<string, { address: string }>;
};