Quick Start
This section shows code examples on how to get started in different languages using Defire's libraries.
JavaScript & Node
1. Install the library.
1
npm install defire
Copied!
2. Create an Ethereum account and fund it with some Rinkeby ethers.
3. Initialize Defire library with that Ethereum account.
1
const defire = Defire({
2
address: "[INSERT ADDRESS OF ETHEREUM ACCOUNT]" ,
3
web3js: web3
4
}, { network: "rinkeby" }
5
);
Copied!
4. Buy Some DAI in Uniswap
1
const operationBuy = new defire.Operations.Uniswap.Trade.ETH.For.DAI({
2
amountETH: "500000000000000000" // 0.5 ETH
3
});
4
await defire.actions.execute(operationBuy);
Copied!
5. Get your current DAI balance
1
const balance = await defire.query.balance(defire.Assets.DAI);
Copied!
6. Lend all your DAI in Compound
1
const operationLend = new defire.Operations.Compound.Lend.DAI({
2
amountDAI: balance // 100% of DAI balance
3
});
4
await defire.actions.execute(operationLend);
Copied!
Congrats! You have bought DAI and lent it with a few lines of code.
😃
Consider using a portfolio. Check why they are safer.
Last modified 1yr ago
Copy link