Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating Ethereum Contracts (go ethereum)

Tags:

ethereum

Trying to follow the wiki example for go ethereum to create a basic contract: https://github.com/ethereum/go-ethereum/wiki/Contracts-and-Transactions

Everything seems to work until I get down until the last line:

source = "contract test { function multiply(uint a) returns(uint d) { return a * 7; } }"
contract = eth.compile.solidity(source).test
primaryAddress = eth.accounts[0]

# **Problems start here **
MyContract = eth.contract(abi);
contact = MyContract.new(arg1, arg2, ...,{from: primaryAddress, data: evmCode})

What is the "abi" argument for the eth.contract method? Also, what would I put in the "evmCode" argument? In this particular example, seems like I would put in an integer for "arg1" but not sure what the full example should look like.

like image 898
Raymond Carl Avatar asked Nov 25 '15 22:11

Raymond Carl


People also ask

Is Ethereum written in Go?

Go Ethereum is one of the three original implementations (along with C++ and Python) of the Ethereum protocol. It is written in Go, fully open source and licensed under the GNU LGPL v3.

Is Go Ethereum an Ethereum client?

Go-Ethereum, popularly referred to as Geth, is the official Ethereum client for building decentralized applications using the Go programming language.

Can I write smart contracts in Go?

In order to interact with a Smart Contract in a Go application, the ABI (application binary interface) of the contract must first be generated, and then compiled so that it can be imported in said application.


1 Answers

ABI is representation of smart contract that can be read using java script .To read the data from a deployed contract account in etherum , you'll need some extra details like abi.

Steps to get abi of any smart contract:

1.Each contract has contract hash address like this:0x0D8775F648430679A709E98d2b0Cb6250d2887EF

2.Go to etherscan.io and search your contract address hash in search bar and you will get contract.

3.In contract go to code and there you can find this abi

can check this link to find abi

like image 102
DeV Avatar answered Oct 13 '22 22:10

DeV