How to interact with a smart contract directly

We’ve all been there. Great project, still working out its front-end, or worse they require you to interact with the contract directly cause some hack or something needs you to withdraw your tokens. HOW I DO DIS?

In this short tutorial I’ll break it down in a few ways you can do this.

Things you’ll need

First thing you’ll need is the ERC20 contract! IF you don’t have the contract address get it from an official admin from a tg you care about or you can get it from dextools usually.

Click the copy next to the token contract.

So how do we interact with the contract?

Once you have that go over to https://etherescan.io and put it (0xAd4f86a25bbc20FfB751f2FAC312A0B4d8F88c64) into the filter. It should bring you here.

Click the green check mark under Contract to view the contract.

After clicking the Contract tab you should see:

Connect to Web3 will prompt you to connect your metamask.

From this point you’ll be able to use the functions directly on the contract with your wallet.

Eth95.dev

If you haven’t used this yet then Eth95.exe is an awesome interface that mimics the above pretty nicely. Grab the contract address.

Click “Add Contract”

Inputting the token in this case the top trending on DT right now ($ROOM) should look like this:

Click Etherscan and put the contract address under Address

You should now be able to call the contract functions (as long as you make sure you “Connect” with your Metamask

Click Connect

And voila!

You’ll need the source code of the contract that you can get via github usually or directly on etherscan (if its a verified contract).

Copy source code to clipboard on the upper right.

Then navigate to https://remix.ethereum.org

Create a new file and input the source code into the editor

You’ll end up with something like this:

Make sure your compiler matches the “pragma solidity” version

You should then click “Compile Room.sol” (or whatever you named it) and should end up with the green checkmark (on the left). Once you have that you can click the 3rd tab (eth looking one).

If you don’t see Roomtoken under contract it should be there underneath if you browse to it.

Now enter the contract address 0xAd4f86a25bbc20FfB751f2FAC312A0B4d8F88c64 under “At address”

When you do that you should now see something like:

Almost there!

Before you can interact with the contract you’ll need to make sure that you’re environment is set to use your web3 (Metamask).

Not javascriptVM default

And BOOM. Now you don’t ever need to worry about a front-end being broken. And can get up to date data directly on any contract that is publicly available. At this point you’re 1 step away from being able to launch a project now to mainnet. But I’ll leave that for another post. Will also be posting more details on DOGIRA as we finish up the contract audit with War On Rugs.

Hope this has helped. You’re welcome. ;) Feel free to msg me on twitter Andre Musk or @andremusk on tg.