Skip to content

Instantly share code, notes, and snippets.

@RobertoC27
Created November 11, 2018 19:57
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 RobertoC27/4900705b2a01d4253402964d85177a09 to your computer and use it in GitHub Desktop.
Save RobertoC27/4900705b2a01d4253402964d85177a09 to your computer and use it in GitHub Desktop.
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>test</title>
</head>
<body>
<script src="https://cdn.jsdelivr.net/gh/ethereum/web3.js@1.0.0-beta.35/dist/web3.min.js"></script>
<script type="text/javascript">
if (typeof window.web3 !== "undefined") {
var web3latest = new Web3(window.web3.currentProvider);
console.log('jeje');
} else {
var provider = new Web3.providers.HttpProvider('node_Address');
var web3latest = new Web3(provider);
console.log('ojj');
}
</script>
<script src="index.js"></script>
</body>
</html>
console.log(web3latest.version);
const abi = [
{
"constant": true,
"inputs": [
{
"name": "",
"type": "address"
},
{
"name": "",
"type": "uint256"
}
],
"name": "walletStore",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "view",
"type": "function",
"signature": "0xb7a004f1"
},
{
"constant": true,
"inputs": [
{
"name": "",
"type": "uint256"
}
],
"name": "assets",
"outputs": [
{
"name": "name",
"type": "string"
},
{
"name": "description",
"type": "string"
},
{
"name": "manufacturer",
"type": "string"
},
{
"name": "price",
"type": "uint256"
},
{
"name": "id",
"type": "uint256"
},
{
"name": "owner",
"type": "address"
},
{
"name": "initialized",
"type": "bool"
}
],
"payable": false,
"stateMutability": "view",
"type": "function",
"signature": "0xcf35bdd0"
},
{
"constant": false,
"inputs": [
{
"name": "_name",
"type": "string"
},
{
"name": "_description",
"type": "string"
},
{
"name": "_manufacture",
"type": "string"
},
{
"name": "_price",
"type": "uint256"
},
{
"name": "id",
"type": "uint256"
}
],
"name": "createAsset",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function",
"signature": "0xfe3f41cb"
}
]
async function setup() {
const instance = await new web3latest.eth.Contract(abi, "0xc9159ccd6a040a4fae34728d2a27163ccd8f768d");
const a1 = await instance.methods.assets(0).call();
console.log(a1);
}
setup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment