View your deployed Smart Contract on Amberdata.io
We’ll be looking at how to deploy a smart contract with truffle and view that recently deployed contract on the Amberdata.io platform.
TLDR; Scroll to the bottom for the video tutorial!
0. Select Rinkeby
Before doing anything we’ll set our network to Rinkeby since we’ll be working with the Rinkeby network.
1. Signup/Login
Begin by either logging in with an existing account or creating a new one here.
2. Deploy to Rinkeby
I’m using a completed version of the Ethereum Pet Shop Tutorial. Run the following command to deploy the contract to the Rinkeby network:
❯ truffle migrate --network rinkeby
Like so…
3. Snatch the hash!
If everything ran correctly you should be able to see both the transaction hash and the contract address.
So let’s copy them.
4. View it! 👀
Paste the hashes into the search bar to see details about the recently deployed contract on our platform.
Voilà! Here’s the transaction that deployed the Adoptions
contract to Rinkeby. Neat-o!
Note: Look at the from
address. It should be the same as your developer wallet if you’ve had a chance to set it. If not check out this video!
We can do the same with the contract address although there won’t be much to see until we interact with the contract. So let’s do that!
5. Interacting with the contract
First we want to fire up the truffle console. This gives us direct access to the deployed contract on Rinkeby. It additionally comes with web3.js built in!
❯ truffle console --network rinkeby
Next, we’ll create a reference to the deployed Adoptions
contract instance.
contract = Adoptions.at("0x...")
Like this
Awesome! Now that we have the contract instance we can interact with it. If you look at the code for the Adoptions
contract you’ll notice an adopt(uint petId)
method. We’ll call this method to adopt pet1
.
Enter the following command in the truffle console:
truffle(rinkeby)> contract.adopt(1)
If the transaction was successful you should see a json output of the transaction data. You can find the transactionHash
at the bottom, copy, and paste it into Amberdata.io just like we did before.
Finally we are going to view the Activity Panel of the Adoptions
contract.
First search for the contract by address.
Then, go to the console tab and…
There it is! That’s the method we just called. Gadzooks!
Within seconds of the transaction being confirmed our platform was able to detect and update the UI, thus, enabling you to view, in real time, the interactions with your contract. In another post, we discuss in greater detail the contract console page.
Here’s the video going over everything we just discussed (if you’re more into watching 🎞 than reading 📖).