简体   繁体   English

未捕获的错误:u处的无效地址(web3.min.js:1)

[英]Uncaught Error: invalid address at u (web3.min.js:1)

I am writing an simple Smart Contract with Solidity but it shows an error I can't fix. 我正在编写带有Solidity的简单智能合约,但显示了我无法修复的错误。 Here is my code: 这是我的代码:

<div class="container">

    <h1>Information</h1>

    <h2 id="form"></h2>

    <label for="name">Name</label>
    <input id="name" type="text">

    <label for="name">Age</label>
    <input id="age" type="text">

    <button id="button">Update Infomation</button>


</div>

Skript: 斯克里普特:

if (typeof web3 !== 'undefined') {
        web3 = new Web3(web3.currentProvider);
    } else {
       web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
    }

    web3.eth.defaultAccount = web3.eth.accounts[0];

    var SmartContract = web3.eth.contract(ABI);

    var ContractAddress= SmartContract.at(Address);

    ContractAddress.getInformation(function(error, result){
       if(!error)
           {
               $("#form").html(result[0]+' ('+result[1]+' years old)');
               console.log(result);
           }
       else
           console.log(error);
   });

   $("#button").click(function() {
       ContractAddress.setInformation($("#name").val(), $("#age").val());
   });

The Solidity-Code is simple: Solidity-Code很简单:

contract information{

   string fName;
   uint age;

   function setInformation(string _fName, uint _age) public {
       fName = _fName;
       age = _age;
   }

   function getInformation() public constant returns (string, uint) {
       return (fName, age);
   }

}

In the console it shows the error: 在控制台中,它显示错误:

Uncaught Error: invalid address at u (web3.min.js:1) at inputCallFormatter (web3.min.js:1) at web3.min.js:1 at Array.map () at i.formatInput (web3.min.js:1) at i.toPayload (web3.min.js:1) at _.e [as call] (web3.min.js:1) at c.call (web3.min.js:1) at c.execute (web3.min.js:1) at index.html:85 未捕获的错误:i.formatInput(web3.min。 js.1)位于_.e的i.toPayload(web3.min.js:1),位于c.call(web3.min.js:1)处于[调用时](web3.min.js:1)。在index.html:85执行(web3.min.js:1)

I tried to add something like personal.unlockAccount(web3.eth.defaultAccount) but it doesn's fixed it. 我试图添加诸如personal.unlockAccount(web3.eth.defaultAccount)类的东西,但是它没有解决问题。

You need to provide the address of the deployed smart contract. 您需要提供已部署的智能合约的地址。

You will get smartcontract address while deploying the smart contract. 部署智能合约时,您将获得智能合约地址。 you need to with use the same network what you used to deploy. 您需要使用与部署相同的网络。

For Reference 以供参考

https://github.com/praveenkakumanu/Ethereum/blob/master/sample/index.html https://github.com/praveenkakumanu/Ethereum/blob/master/sample/index.html

if you running web3js as node_modules you need to use the above web3@0.18 version 如果将web3js作为node_modules运行,则需要使用上述web3@0.18版本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:找不到模块“ ipfs” web3.min.js:1:155 - Error: Cannot find module 'ipfs' web3.min.js:1:155 leaflet.js:未捕获的错误:无效的LatLng对象:(NaN,NaN) - leaflet.js: Uncaught Error: Invalid LatLng object: (NaN, NaN) 不允许加载本地资源,以及angular.min.js:35未捕获的错误:[$ injector:modulerr] - not allowed to load local resource, and angular.min.js:35 Uncaught Error: [$injector:modulerr] 未捕获的错误:Bootstrap 的 JavaScript 需要 electron 应用程序中 bootstrap.min.js:6 处的 jQuery - Uncaught Error: Bootstrap's JavaScript requires jQuery at bootstrap.min.js:6, in an electron app 未捕获的错误节点Js - Uncaught error Node Js 错误:ChatConnector:startConversation-地址无效 - Error : ChatConnector: startConversation - address is invalid 未捕获的SyntaxError:意外的令牌&lt;jquery.min.js:1 - Uncaught SyntaxError: Unexpected token < jquery.min.js:1 angular.min.js:1未捕获的SyntaxError:意外令牌 - angular.min.js:1 Uncaught SyntaxError: Unexpected token < 未捕获的语法错误:JSON 中的意外令牌 u 在 JSON.parse 的 position 0 处(<anonymous> ) at./src/context/AuthContext.js</anonymous> - Uncaught SyntaxError: Unexpected token u in JSON at position 0 at JSON.parse (<anonymous>) at ./src/context/AuthContext.js 在节点js中未定义Mustache错误:未捕获错误 - Mustache is not defined error in node js : Uncaught error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM