Skip to main content

Connect To A Contract

For smart contracts deployed using thirdweb via the dashboard or deploy, provide it's address to the GetContract method to get a contract instance.

// Ensure your sdk is initialized to the same network as the contract
Contract contract = sdk.GetContract("<your-smart-contract-address>");

The Contract instance has type-safe functionality to interact with your smart contracts, including:

Marketplaces

If you're using the Marketplace, you can access that in the contract's marketplace field:

Marketplace marketplace = contract.marketplace;

Using Contract ABI

For any smart contract that is not deployed using thirdweb, you can provide the contract's ABI as a second argument to the GetContract method to get an instance of it.

Contract contract = sdk.GetContract("<your-smart-contract-address>", "<your-contract-abi>");