IDEを使ってブロックチェーンのフリマサイトを作ろうと思っています
xamppを使って動作を確認していたところ
metamuskのテストネットの環境設定ができていないのかjsから「metamusk」をインストールして下さいと出ました。
検証ツールを使って見てみるとこの様にエラーが出ていました。
「Uncaught ReferenceError: abi is not defined」
contract = new web3js.eth.Contract(abi,address);
abiのファイルを確認しましたが特に問題はなさそうでした。
ABIが定義出来てないだけなのかインスタンスが生成出来ません。
サイトの投稿や会員登録が正常に動かせる様にしたいです。
教えていただける方はいらっしゃいますでしょうか。。
以下ファイルの記述です。
check.js
if (typeof web3 !== "undefined") { web3js = new Web3(web3.currentProvider); } else { alert("MetaMaskをインストールして下さい。"); } web3js.eth.getAccounts(function(err, accounts) { coinbase = accounts[0]; console.log("coinbase is " + coinbase); if (typeof coinbase === "undefined") { alert("MetaMaskを起動してください。") } }); const address = "スマートコントラクトのアドレス"; contract = new web3js.eth.Contract(abi,address);⬅️Uncaught ReferenceError: abi is not defined
ABI
abi = [ { "constant": false, "inputs": [ { "name": "_numItems", "type": "uint256" } ], "name": "buy", "outputs": [], "payable": true, "stateMutability": "payable", "type": "function" }, { "constant": false, "inputs": [ { "name": "_numItems", "type": "uint256" }, { "name": "_reputate", "type": "int256" } ], "name": "buyerEvaluate", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [], "name": "kill", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "_name", "type": "string" }, { "name": "_email", "type": "string" } ], "name": "modifyAccount", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "_numItems", "type": "uint256" }, { "name": "_name", "type": "string" }, { "name": "_description", "type": "string" }, { "name": "_price", "type": "uint256" }, { "name": "_googleDocID", "type": "string" }, { "name": "_IPFSHash", "type": "string" } ], "name": "modifyItem", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "_numItems", "type": "uint256" } ], "name": "ownerStop", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "_numItems", "type": "uint256" } ], "name": "receive", "outputs": [], "payable": true, "stateMutability": "payable", "type": "function" }, { "constant": false, "inputs": [ { "name": "_numItems", "type": "uint256" } ], "name": "refundFromOwner", "outputs": [], "payable": true, "stateMutability": "payable", "type": "function" }, { "constant": false, "inputs": [ { "name": "_numItems", "type": "uint256" } ], "name": "refundFromSeller", "outputs": [], "payable": true, "stateMutability": "payable", "type": "function" }, { "constant": false, "inputs": [ { "name": "_name", "type": "string" }, { "name": "_email", "type": "string" } ], "name": "registerAccount", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "_name", "type": "string" }, { "name": "_description", "type": "string" }, { "name": "_price", "type": "uint256" }, { "name": "_googleDocID", "type": "string" }, { "name": "_ipfsHash", "type": "string" } ], "name": "sell", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "_numItems", "type": "uint256" }, { "name": "_reputate", "type": "int256" } ], "name": "sellerEvaluate", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "_numItems", "type": "uint256" } ], "name": "sellerStop", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "_numItems", "type": "uint256" } ], "name": "ship", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "_stopped", "type": "bool" } ], "name": "toggleCircuit", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "payable": false, "stateMutability": "nonpayable", "type": "constructor" }, { "constant": true, "inputs": [ { "name": "", "type": "address" } ], "name": "accounts", "outputs": [ { "name": "name", "type": "string" }, { "name": "email", "type": "string" }, { "name": "numTransactions", "type": "uint256" }, { "name": "reputations", "type": "int256" }, { "name": "resistered", "type": "bool" }, { "name": "numSell", "type": "int256" }, { "name": "numBuy", "type": "int256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "", "type": "address" }, { "name": "", "type": "uint256" } ], "name": "buyItems", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "", "type": "uint256" } ], "name": "images", "outputs": [ { "name": "googleDocID", "type": "string" }, { "name": "ipfsHash", "type": "string" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "", "type": "uint256" } ], "name": "items", "outputs": [ { "name": "sellerAddr", "type": "address" }, { "name": "buyerAddr", "type": "address" }, { "name": "seller", "type": "string" }, { "name": "name", "type": "string" }, { "name": "description", "type": "string" }, { "name": "price", "type": "uint256" }, { "name": "payment", "type": "bool" }, { "name": "shipment", "type": "bool" }, { "name": "receivement", "type": "bool" }, { "name": "sellerReputate", "type": "bool" }, { "name": "buyerReputate", "type": "bool" }, { "name": "stopSell", "type": "bool" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "numItems", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "", "type": "uint256" } ], "name": "refundFlags", "outputs": [ { "name": "", "type": "bool" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "", "type": "address" }, { "name": "", "type": "uint256" } ], "name": "sellItems", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "stopped", "outputs": [ { "name": "", "type": "bool" } ], "payable": false, "stateMutability": "view", "type": "function" } ]
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。