using truffle and geth to compile and deploy a contract

try to deploy the contract into the Rinkeby network.

geth, truffle.

1. using vim to edit a solidity contract.

2. add a entry of Rinkeby into the truffle.js, so truffle can connect to the Rinkeby network. code:

rinkeby: {

host: "127.0.0.1",

port: 8545,

from:"any account address for default deployment",

network_id: "4",// Match Rinkeby

gas:4612388

}

3. truffle compile

4. add a migration file into the migrations dir

5. truffle migrate --network rinkeby

before 5) need to start geth and unlock your account:

geth --rinkeby --rpc --rpcapi db,eth,net,web3,personal --unlock="your account address"

Details can be referred to?

https://blog.abuiles.com/blog/2017/07/09/deploying-truffle-contracts-to-rinkeby/


When to interact with a deployed contract on Rinkeby, try the following steps:

0. u need to get the ABI and address of the deployed contract.

u can search them on the etherscan website (https://rinkeby.etherscan.io/ for rinkeby)

If you want to interact with your own contract, then you need to verify your contract with source code first. By doing so you can obtain the ABI (remember to export as Json format).?

When you verify your contract, the website may ask you to provide the complier version (I find that although we declare the compiler version in the contract, the truffle seems to use its own version to compile it....So what is the point in declaring version in the code...), if you cannot decide the truffle default version, you can go the build dir and find the built file to find the version value. Or, I think you can also directly use truffle version to get the compiler version. Any way, try.

1. After you get the ABI and the address of the contract that you want to interact with through geth, you then can use them to get an instance of the contract, after that, you can call its functions.

abi=[xxx]; the xxx is the exported Json format of ABI.

// creation of contract object

var MyContract = web3.eth.contract(abi);

// initiate contract for an address

var myContractInstance = MyContract.at("contract address");

// call constant function

var result = myContractInstance.myConstantMethod('myParam');

console.log(result) // '0x25434534534'

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子士袄,更是在濱河造成了極大的恐慌闪萄,老刑警劉巖锥累,帶你破解...
    沈念sama閱讀 216,997評(píng)論 6 502
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件侍匙,死亡現(xiàn)場(chǎng)離奇詭異成翩,居然都是意外死亡沟突,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,603評(píng)論 3 392
  • 文/潘曉璐 我一進(jìn)店門(mén)捕传,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)惠拭,“玉大人,你說(shuō)我怎么就攤上這事庸论≈案ǎ” “怎么了?”我有些...
    開(kāi)封第一講書(shū)人閱讀 163,359評(píng)論 0 353
  • 文/不壞的土叔 我叫張陵聂示,是天一觀的道長(zhǎng)域携。 經(jīng)常有香客問(wèn)我,道長(zhǎng)鱼喉,這世上最難降的妖魔是什么秀鞭? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 58,309評(píng)論 1 292
  • 正文 為了忘掉前任,我火速辦了婚禮扛禽,結(jié)果婚禮上锋边,老公的妹妹穿的比我還像新娘。我一直安慰自己编曼,他們只是感情好豆巨,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,346評(píng)論 6 390
  • 文/花漫 我一把揭開(kāi)白布。 她就那樣靜靜地躺著掐场,像睡著了一般往扔。 火紅的嫁衣襯著肌膚如雪贩猎。 梳的紋絲不亂的頭發(fā)上,一...
    開(kāi)封第一講書(shū)人閱讀 51,258評(píng)論 1 300
  • 那天萍膛,我揣著相機(jī)與錄音吭服,去河邊找鬼。 笑死蝗罗,一個(gè)胖子當(dāng)著我的面吹牛噪馏,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播绿饵,決...
    沈念sama閱讀 40,122評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼瓶颠!你這毒婦竟也來(lái)了拟赊?” 一聲冷哼從身側(cè)響起,我...
    開(kāi)封第一講書(shū)人閱讀 38,970評(píng)論 0 275
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤粹淋,失蹤者是張志新(化名)和其女友劉穎吸祟,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體桃移,經(jīng)...
    沈念sama閱讀 45,403評(píng)論 1 313
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡屋匕,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,596評(píng)論 3 334
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了借杰。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片过吻。...
    茶點(diǎn)故事閱讀 39,769評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖蔗衡,靈堂內(nèi)的尸體忽然破棺而出纤虽,到底是詐尸還是另有隱情,我是刑警寧澤绞惦,帶...
    沈念sama閱讀 35,464評(píng)論 5 344
  • 正文 年R本政府宣布逼纸,位于F島的核電站,受9級(jí)特大地震影響济蝉,放射性物質(zhì)發(fā)生泄漏杰刽。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,075評(píng)論 3 327
  • 文/蒙蒙 一王滤、第九天 我趴在偏房一處隱蔽的房頂上張望贺嫂。 院中可真熱鬧,春花似錦雁乡、人聲如沸涝婉。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 31,705評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)墩弯。三九已至吩跋,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間渔工,已是汗流浹背锌钮。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 32,848評(píng)論 1 269
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留引矩,地道東北人梁丘。 一個(gè)月前我還...
    沈念sama閱讀 47,831評(píng)論 2 370
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像旺韭,于是被迫代替她去往敵國(guó)和親氛谜。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,678評(píng)論 2 354

推薦閱讀更多精彩內(nèi)容