Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<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
You can’t perform that action at this time.