Skip to content

Instantly share code, notes, and snippets.

View cleancoindev's full-sized avatar
🦦
OtterMarkets eh? *rolls eyes*

cleancoindev

🦦
OtterMarkets eh? *rolls eyes*
View GitHub Profile
@cleancoindev
cleancoindev / supply-erc20-via-solidity.js
Created March 24, 2020 19:25 — forked from ajb413/supply-erc20-via-solidity.js
This is the script to run the supply contract into the blockchain/CompoundedCarbon protocol
const main = async function() {
console.log('Now transferring DAI from my wallet to MyContract...');
let transferResult = await daiContract.methods.transfer(
myContractAddress,
web3.utils.toHex(10e18) // 10 DAI to send to MyContract
).send({
from: myWalletAddress,
gasLimit: web3.utils.toHex(150000), // posted at compound.finance/developers#gas-costs
gasPrice: web3.utils.toHex(20000000000), // use ethgasstation.info (mainnet only)
@cleancoindev
cleancoindev / MyContracts.sol
Created March 24, 2020 19:22 — forked from ajb413/MyContracts.sol
This is how to supply CompounedCarbon ERC20s into the compound protocol.
contract MyContract {
event MyLog(string, uint256);
function supplyErc20ToCompound(
address _erc20Contract,
address _cErc20Contract,
uint256 _numTokensToSupply
) public returns (uint) {
// Create a reference to the underlying asset contract, like DAI.
Erc20 underlying = Erc20(_erc20Contract);
const { Cert } = require('@0xcert/cert');
const { HttpProvider } = require('@0xcert/ethereum-http-provider');
const { AssetLedger } = require('@0xcert/ethereum-asset-ledger');
(async () => {
const schema = {
"$schema": "http://json-schema.org/draft-07/schema",
"description": "A digital assets that have a unique combination of different properties.",
"properties": {