-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathipfs.js
More file actions
44 lines (43 loc) · 963 Bytes
/
ipfs.js
File metadata and controls
44 lines (43 loc) · 963 Bytes
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
40
41
42
43
44
var ethers = require('ethers');
var url = 'https://morning-withered-sun.ropsten.discover.quiknode.pro/e45811e314c541fc884553139807270b9b46c702/';
var provider = new ethers.providers.JsonRpcProvider(url);
var address = '0x1E071c3E438531D69f552cD27DeA90826692f88e';
var abi = [
{
"inputs": [],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [],
"name": "getHash",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "string",
"name": "x",
"type": "string"
}
],
"name": "sendHash",
"outputs": [],
"stateMutability": "nonpayable",
"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;
};
});