[英]Solidity w/ Rinkeby Test Network | Uncaught Error: invalid address
I'm taking an intro to Blockchain class and am trying to deploy my project onto a web hosting site.我正在介绍区块链课程,并试图将我的项目部署到网络托管站点上。 When I execute my program locally, it works fine and metamask is able to process transactions properly.当我在本地执行我的程序时,它工作正常并且 metamask 能够正确处理事务。 Upon putting my project up on the webhost, I get error:将我的项目放在虚拟主机上后,出现错误:
Uncaught Error: invalid address未捕获的错误:无效地址
What can I do to fix this?我能做些什么来解决这个问题? Here is my JS: (Note: the init and metamask stuff was all written by my professor)这是我的 JS:(注意:init 和 metamask 的东西都是我的教授写的)
function init () {
let button1 = document.querySelector ("#button1");
button1.addEventListener ("click", buttonPress);
let button2 = document.querySelector ("#button2");
button2.addEventListener ("click", cashout);
// load Demo1.abi.json obtained from the Compiler tab of Remix
// (click the ABI button and save the clipboard contents to the file)
fetch ("./countdown.abi.json")
.then (function (response) {
return response.json ();
})
.then (function (abi) {
window.abi = abi;
});
}
function getInstance () {
let contractAddress = "hiddenContractAddress";
if (contractAddress === "") {
console.err ("no contract address set");
}
let factory = web3.eth.contract (window.abi);
let instance = factory.at (contractAddress);
return instance;
}
function buttonPress(evt) {
let instance = getInstance ();
let sender = web3.eth.accounts[0];
instance.buttonClick ({
from : sender,
value : 100000000000000000,
gas : 200000
},
function (error, result) {
if (!error) {
let currentwinner = document.querySelector ("#currentwinner");
if (sender == currentwinner.value){
window.alert("Unable to process transaction: You are already winning!");
console.log(result);
}
else{
window.alert("Your button press has been processed!");
console.log(result);
}
} else {
console.error (`get error: ${error}`);
}
}
);
}
我想您应该使用另一个地址,而不是您测试时使用的本地地址。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.