forked from MolochVentures/moloch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathipfs.js
39 lines (38 loc) · 842 Bytes
/
ipfs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
var ethers = require('ethers');
var url = 'https://rinkeby.infura.io/v3/d00f341268954cc79fe46df8c67d4aa0';
var provider = new ethers.providers.JsonRpcProvider(url);
var address = '0xD3375e8dce2C5E414881328F576568CF178ea705';
var abi = [
{
"inputs": [
{
"internalType": "string",
"name": "x",
"type": "string"
}
],
"name": "sendHash",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "getHash",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
}
];
var contract = new ethers.Contract(address,abi,provider);
contract.getHash().then((result) =>{
document.getElementById("btn").onclick = function () {
location.href = "https://ipfs.io/ipfs/"+result;
};
});