Using GoChain with Link
In this onboarding example, we will deploy a smart contract on the GoChain Testnet.
Ask for some free testnet GO in GoChain’s Testnet Telegram to be sent to your Link account
- In Link, open up the setting dropdown menu and select
New Projectwhich starts the new project wizard.
- Under Which contract would you like to use? select
Ownershipif the contract already exists, or select
Create newand then copy and paste the
Ownership.solcode into the Source Code field. Set the Display Name as
- Under Which Ethereum account would you like to use?, use the
Default Account. This is the account we seeded with test GO tokens as part of the setup.
- Under Which network would you like to use?, select
Create newand call it
GoChain Testnet. Keep the Block Confirmations Needed at 0. Press
- Under Which connector would you like to use?, select
Create new. Call this connector
GoChain Testnet Connectorand use the URL
https://testnet-rpc.gochain.io(see https://github.com/gochain-io/docs#network-rpc-urls for more details). Ensure the Network selected is
GoChain Testnet. Press
- Now we just need to label our Deployment. Under Where is your contract deployed?, select
Create new. Call this deployment
Ownership GoChain Testnet Deployment. Since we do not have an existing contract deployment, leave the Address field blank. Ensure the Account is the
Default Account, the Contract is the
Ownershipcontract and the Network
GoChain Testnet. Press
- Now we’re ready to deploy our contract to the GoChain Testnet. Press
Deployand you should get a deployment in progress indicator icon. This might take a few seconds to complete. If deployed correctly, you’ll proceed to the next step to set up your API.
- Now we label our Ownership contract API. Under Name, call it
ownership-gochain-testnetAlso add in a human-readable display name. Ensure you are using the correct Contract Deployment. Press
- Now we label our Ownership API Consumer. This would normally be the name of the app or service calling the API. For example, let’s call the consumer
Collectible Stamps App Ropsten. Ensure you are using the correct APIand Account. Press
- Lastly, your consumer needs to authenticate with the Ownership API. An OAuth2.0 Client Secret is automatically generated. Ensure you are using the correct Principal/Consumer. Press
Once you hit
Finish, you should see your Ownership API documentation. Note the
client_secret under Authentication which you will use in your app.
Let’s also check that our Ownership contract deployed correctly on the GoChain Testnet. Click on the
Ethereum Contract Deployments menu item to see a list of contract deployments and their addresses. Copy and paste the address of the
Ownership GoChain Testnet Deployment into the GoChain Testnet explorer https://testnet-explorer.gochain.io to see the details of your contract deployment.
In the above example, the contract address on GoChain is
And we see our contract deployed on GoChain!
Now you can go ahead and use the API endpoints which are linked to the Ownership smart contract deployed on GoChain Testnet!
Simply update the
Client Secretfor authentication.
Then run the
ownership-link-sdk-demo.jsscript using Node from a Terminal for example. You should see an output in Terminal similar to the following:
Check your Ownership contract using the GoChain Testnet Explorer to confirm the new transactions representing the
If you want to deploy on the GoChain Mainnet, just follow the same steps above with the following differences:
Acquire mainnet GO tokens to send to your Link default account wallet
Use the use the appropriate GoChain Network RPC URL for Mainnet