1

I'm building a Web3 app and I'm trying it out on the Kovan testnet. I'm trying to get some DAI. As far as I understand it the way to get DAI is to:

  1. Exchange ETH for WETH.
  2. Use Sai Tub contract to open a CPD.
  3. Use Sai Tub contract to exchange WETH for PETH.
  4. Exchange PETH for DAI.

I got step one and two done. Now I'm trying to call the Sai Tub contract to get some PETH (all those recent failed transactions were me 🙈), but it rejects all requests.

Here is how I'm calling it:

async function wrapETH({ amountToWrapInEth, from }) {
  const Weth = new window.web3.eth.Contract(wethABI, wethAddress);
  const amountToWrapInWei = window.web3.utils.toWei(amountToWrapInEth);
  const receipt = await Weth.methods
    .deposit()
    .send({ from, value: amountToWrapInWei, gas: 90000 });
  return receipt;
}

async function openCPD(from) {
  const SaiTub = new window.web3.eth.Contract(saiTubABI, saiTubAddress);
  const receipt = await SaiTub.methods.open().send({ from, gas: 90000 });
  return receipt;
}

async function joinPool({ amountToPoolInWETH, from }) {
  const SaiTub = new window.web3.eth.Contract(saiTubABI, saiTubAddress);
  const receipt = await SaiTub.methods
    .join(amountToPoolInWETH)
    .send({ from, gas: 90000 });
  return receipt;
}

What am I doing wrong? How do you programatically obtain DAI using Web3? Does it have something to do with CDP?

BTW, if you could point me to another way of exchanging ETH directly with DAI on Kovan, that would help me out, too (even though ultimately I will have to solve the aforementioned problem). Thank you for any help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.