目前,我正在react.js
的帮助下建立一个简单的彩票合同。这是我的app.js
文件在react.js
与web3
,彩票合同是工作良好的混音找不到这个文件中的错误。
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import web3 from './web3';
import lottery from './lottery';
class App extends Component {
constructor(props) {
super(props);
this.state = { manager: '' };
}
async componentDidMount() {
const manager = await lottery.methods.manager().call();
this.setState({ manager });
}
render(){
return (
<div>
<h2> Lottery contract</h2>
<p>this contract if managed by {this.state.manager}</p>
</div>
);
}
}
export default App;
彩票网站
import web3 from './web3';
const address = '0xBEFF762b1A78D1263b43e72630843D093B5c36d4';
const abi = [
{"constant":false,"inputs":[{"name":"newMessage","type":"string"}],"name":"setMessage","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"message","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"initialMessage","type":"string"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}];
export default new web3.eth.Contract(abi, address);
1条答案
按热度按时间7cjasjjr1#
您的ABI阵列似乎没有名为
manager
的函数,因此可能会引发错误default.methods.manager is not a function
。ABI阵列中的函数只有
setMessage
和message
。