0

I want to access API's from a smart contract deployed on Ropsten network. This smart contract is written and deployed by some external entity and they have exposed API's. I know the smart contract address, solidity file (as source code is open),API's to call. I want to know by which way i can connect Ropsten network from my local machine and call required API's.

Their documentations are not clear, so even after trying multiple options i could not able to make it.

Please let me know if is there any way to do this. Let me know if require any further information

1

I understand that by 'API' you mean the contract functions. There are several ways:

Option 1: MyEtherwallet (or myCrypto):

Find contract ABI:

solc --abi contractSourceCode.sol

Go to: https://www.myetherwallet.com/#contracts

Enter the contract address, the contract ABI and press 'access'. You will be able to interact with the contract

Option 2: Use geth and Infura

Register at infura.io and get a token

Connect to ropsten using Infura

geth attach https://ropsten.infura.io/<your-token>

Now that you are in a geth console:

var cont = eth.contract(<contract ABI>).at(<contract address>)

Then, you can run the contract functions by:

cont.functionName()

Where "functionName" is any function the contract has (note that writing cont. and pressing tab will autocomplete.

There are other ways, but for me those 2 are the simplest ones.

1

If the contract is verified in etherscan (as you mentioned it is open), then you just go to "write contract" section. And call any functions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.