Re: [閒聊] web3怎麼使用合約

看板DigiCurrency作者 (komica123)時間5年前 (2018/08/08 18:56), 5年前編輯推噓1(104)
留言5則, 1人參與, 5年前最新討論串2/2 (看更多)
※ 引述《Tim20502 (恩)》之銘言: : 最近在連接testrpc可以使用合約,但在轉換到metamask使用的時候就發現這個問題… : https://i.imgur.com/bBu9kVR.jpg
Metamask不支援sync function call 一定要用callback的方式取值 範例 (需Metamask ropsten) https://output.jsbin.com/yihegurowu Contract pragma solidity ^0.4.24; contract PTT { function hello () public pure returns (string) { return 'Hello PTT'; } } Contract Address 0x100e3d1600788d4606107120fdf30ec6657e412a JS const ABI = [ { "constant": true, "inputs": [], "name": "hello", "outputs": [ { "name": "", "type": "string" } ], "payable": false, "stateMutability": "pure", "type": "function" } ]; const PttContract = web3.eth.contract(ABI); const ptt = PttContract.at("0x100e3d1600788d4606107120fdf30ec6657e412a"); ptt.hello((err,result) => document.getElementById("output").innerHTML = result); -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.227.169.72 ※ 文章網址: https://www.ptt.cc/bbs/DigiCurrency/M.1533725813.A.A59.html ※ 編輯: ousapas (36.227.169.72), 08/08/2018 19:30:04

08/08 23:18, 5年前 , 1F
謝謝
08/08 23:18, 1F

08/09 14:14, 5年前 , 2F
這是我改的,但還是沒反應…
08/09 14:14, 2F

08/09 14:14, 5年前 , 3F

08/09 14:14, 5年前 , 4F

08/09 14:14, 5年前 , 5F
文章代碼(AID): #1RQinrfP (DigiCurrency)
文章代碼(AID): #1RQinrfP (DigiCurrency)