Created
November 27, 2019 17:52
-
-
Save jgrizzled/1067cff2b3ecaf61592643d8f9130f4d to your computer and use it in GitHub Desktop.
Melon Infura Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Web3 = require('web3'); | |
const apiKey = 'INSERT_API_KEY'; | |
const web3 = new Web3('https://mainnet.infura.io/v3/' + apiKey); | |
// ABI of called contract | |
const fundRankingAbi = [ | |
{ | |
constant: true, | |
inputs: [{ name: '_factory', type: 'address' }], | |
name: 'getFundGavs', | |
outputs: [ | |
{ name: '', type: 'address[]' }, | |
{ name: '', type: 'uint256[]' } | |
], | |
payable: false, | |
stateMutability: 'view', | |
type: 'function' | |
}, | |
{ | |
constant: true, | |
inputs: [{ name: '_factory', type: 'address' }], | |
name: 'getFundDetails', | |
outputs: [ | |
{ name: '', type: 'address[]' }, | |
{ name: '', type: 'uint256[]' }, | |
{ name: '', type: 'uint256[]' }, | |
{ name: '', type: 'string[]' }, | |
{ name: '', type: 'address[]' } | |
], | |
payable: false, | |
stateMutability: 'view', | |
type: 'function' | |
}, | |
{ | |
constant: true, | |
inputs: [{ name: '_factory', type: 'address' }], | |
name: 'getFundVersions', | |
outputs: [ | |
{ name: '', type: 'address[]' }, | |
{ name: '', type: 'bytes32[]' } | |
], | |
payable: false, | |
stateMutability: 'view', | |
type: 'function' | |
} | |
]; | |
// Address of called contract (mainnet) | |
const fundRankingAddress = '0x4CEc8B644d306CAD99340D13A9fD4A91Fa6d5417'; | |
// Needed for method argument | |
const versionAddress = '0x01Bde0b02740D6311e4a87CA112DeEEddb057EFB'; | |
(async () => { | |
const fundRanking = new web3.eth.Contract(fundRankingAbi, fundRankingAddress); | |
const [fundDetails, fundGavs] = await Promise.all([ | |
fundRanking.methods.getFundDetails(versionAddress).call(), | |
fundRanking.methods.getFundGavs(versionAddress).call() | |
]); | |
console.log(fundDetails, fundGavs); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment