Skip to content

Instantly share code, notes, and snippets.

@Chanutg
Created April 15, 2019 08:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Chanutg/c2c837de4bb2fd2714e5cdb0ed73b554 to your computer and use it in GitHub Desktop.
Save Chanutg/c2c837de4bb2fd2714e5cdb0ed73b554 to your computer and use it in GitHub Desktop.
import React from "react";
import Button from 'react-bootstrap/Button';
class HelloWorld extends React.Component {
state = { sentence: null, newSentence: "", stackId: null };
changeSentence = e => {
this.setState({newSentence: e.target.value});
}
makeTransaction = () => {
const { drizzle, drizzleState } = this.props;
const helloWorld = drizzle.contracts.HelloWorld;
helloWorld.methods["changeSentence"].cacheSend(this.state.newSentence, { from: drizzleState.accounts[0], gas:3000000});
}
componentDidMount() {
const { drizzle, drizzleState } = this.props;
const helloWorld = drizzle.contracts.HelloWorld;
const sentence = helloWorld.methods["saySomething"].cacheCall({ from: drizzleState.accounts[0], gas:3000000});
this.setState({ sentence });
}
render() {
const { HelloWorld } = this.props.drizzleState.contracts;
return (
<div>
<p>Sentence : {HelloWorld.saySomething[this.state.sentence] && HelloWorld.saySomething[this.state.sentence].value}</p>
<input type="text" value={this.state.newSentence} onChange={this.changeSentence}/>
<Button variant="outline-dark" type="submit" value="Submit" onClick={this.makeTransaction}>Send</Button>
</div>
);
}
}
export default HelloWorld;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment