0

I'm totally new to solidity I have a contract that I have to compile and deploy. Now, I have to interact with it (specifically with one of its functions) but I don't know how to do that and I feel that all the threads I found are much more advanced.

Here's the specific function that I have to call:

enter image description here

eth
  • 85,679
  • 53
  • 285
  • 406
Jack.Mc
  • 21
  • 4

2 Answers2

1

Go to http://remix.ethereum.org (Ethereum Solidity IDE in a browser) and:

  1. click on the + at the top left
  2. Copy and paste your code in the main window
  3. Click un "run" tab
  4. Select "JavaScript VM" for the Environment in the top right panel
  5. Select your contract in the panel immediately below the top one and click on "Deploy" button, eventually adding all requested parameters
  6. If deployment is successful, you'll see a new panel at the bottom right with the name of the contract and its address. Click on right arrow to expand it: now you have access to all public variables and functions of your contract.
  7. Add the amount you want to pay to the function claimThrone in the field "value" in the bottom right panel, specifying also the unit (wei, gwei, finney, ether): this is needed because the function is declared as payable
  8. Click on the button labeled claimThrone, adding the the "message" in the text box at its right: your function claimThrone is finally executed. In the panel below your source code you can check the result.
Marco Ottolini
  • 422
  • 4
  • 12
  • HI thanks for your detailed answer , may i ask if you are familiar with the king of Ethur contract ? – Jack.Mc Oct 28 '18 at 11:37
  • If you are referring to https://github.com/kieranelby/KingOfTheEtherThrone/blob/v1.0/contracts/KingOfTheEtherThrone.sol, yes I know what it is, but never "played" to it... – Marco Ottolini Oct 28 '18 at 17:40
0
  1. Install truffle and set up your project via truffle init
  2. Add your previous contracts in the contracts folder and don't forget to set up corresponding migrations
  3. Run truffle develop
  4. Run truffle compile
  5. Run truffle migrate
  6. Now your ContractName will be available in the console. Do:

ContractName.deployed().then(instance => instance.contracts.claimThrone("message").send())

This is merely for development. Take a look on the truffle docs for further deployment to a testnet or the mainnet.

Paul Razvan Berg
  • 17,902
  • 6
  • 73
  • 143