mirror of
https://github.com/embarklabs/embark-create-react-dapp-template.git
synced 2025-02-21 12:28:12 +00:00
feat: Add contract to template, support for latest embark
Add contract as part of the default template. Add support for latest embark (embarkjs-ipfs, embarkjs-whisper).
This commit is contained in:
parent
0198a8825b
commit
ceaba14dcd
17
contracts/SimpleStorage.sol
Normal file
17
contracts/SimpleStorage.sol
Normal file
@ -0,0 +1,17 @@
|
||||
pragma solidity ^0.5.0;
|
||||
|
||||
contract SimpleStorage {
|
||||
uint public storedData;
|
||||
|
||||
constructor(uint initialValue) public {
|
||||
storedData = initialValue;
|
||||
}
|
||||
|
||||
function set(uint x) public {
|
||||
storedData = x;
|
||||
}
|
||||
|
||||
function get() public view returns (uint retVal) {
|
||||
return storedData;
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@
|
||||
"config": "embarkConfig/",
|
||||
"versions": {
|
||||
"web3": "1.0.0-beta",
|
||||
"solc": "0.4.25",
|
||||
"solc": "0.5.0",
|
||||
"ipfs-api": "17.2.4"
|
||||
},
|
||||
"plugins": {
|
||||
|
@ -53,9 +53,9 @@ module.exports = {
|
||||
|
||||
contracts: {
|
||||
// example:
|
||||
//SimpleStorage: {
|
||||
// args: [ 100 ]
|
||||
//}
|
||||
SimpleStorage: {
|
||||
args: [ 100 ]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
16287
package-lock.json
generated
Normal file
16287
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -3,10 +3,13 @@
|
||||
"version": "0.1.0",
|
||||
"dependencies": {
|
||||
"@babel/runtime-corejs2": "^7.3.1",
|
||||
"babel-loader": "^8.0.5",
|
||||
"embarkjs-connector-web3": "4.0.0",
|
||||
"embarkjs-ipfs": "4.0.0",
|
||||
"embarkjs-whisper": "4.0.0",
|
||||
"react": "^16.8.2",
|
||||
"react-dom": "^16.8.2",
|
||||
"react-scripts": "2.1.5",
|
||||
"embarkjs-connector-web3": "4.0.0-beta.0"
|
||||
"react-scripts": "2.1.5"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
|
22
src/DApp.js
22
src/DApp.js
@ -1,8 +1,8 @@
|
||||
/*global web3*/
|
||||
import React from 'react';
|
||||
|
||||
import EmbarkJS from './embarkArtifacts/embarkjs';
|
||||
import config from './embarkArtifacts/config/blockchain';
|
||||
import SimpleStorage from './embarkArtifacts/contracts/SimpleStorage';
|
||||
|
||||
|
||||
class App extends React.Component {
|
||||
@ -18,16 +18,26 @@ class App extends React.Component {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
this.setState({loading: false});
|
||||
SimpleStorage.methods.get().call().then((contractVal) => {
|
||||
this.setState({
|
||||
loading: false,
|
||||
contractVal
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
render() {
|
||||
if (this.state.loading) {
|
||||
return 'Loading...';
|
||||
}
|
||||
return 'Ready!';
|
||||
if (this.state.loading) {
|
||||
return 'Loading...';
|
||||
}
|
||||
return (
|
||||
<React.Fragment>
|
||||
<h3>Value stored in SimpleStorage contract:</h3>
|
||||
{this.state.contractVal}
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user