Compound.js v0.3.1
This version adds the ability to pass Ethers.js provider / wallet / signer objects to the Compound.js read
and trx
methods. This makes it easier to impersonate accounts in the localhost dev environment for testing purposes.
// All of these providers are valid
var provider = window.ethereum;
var provider = 'http://localhost:8545';
var provider = 'https://mainnet.infura.io/v3/xxx....';
var provider = 'ropsten';
var provider = new Compound._ethers.providers.JsonRpcProvider('http://localhost:8545'); // newly supported
var provider = new Compound._ethers.Wallet('0xprivatekey...', ethersProviderObj); // newly supported
var provider = new Compound._ethers.providers.Web3Provider(window.ethereum); // newly supported
const srpb = await Compound.eth.read(
cEthAddress,
'function supplyRatePerBlock() returns (uint256)',
[]
{ provider }
);