0

Drop in smart contract links for ERC-20 stablecoin. There is no list defined anywhere. There should be easy to understand resources in one place for new lerners. what should be the best boilerplate?

1
  • You can find source codes for most projects in Etherscan or Github. Jan 17, 2022 at 11:03

2 Answers 2

0

There's a couple different techniques to ensure a stablecoin maintains its value, so it's not clear if you're looking for a specific type (such as algorithmic stable coins like OHM and DAI) or something else.

I believe USDC/USDT are just fiat backed ERC20s, so it's not necessarily interesting to look at their contract vs. another ERC20. (Here's USDC for reference https://polygonscan.com/address/0xdd9185db084f5c4fff3b4f70e7ba62123b812226#code)

0

I don't have a source for you, however I can write some simple code that'll work as a stablecoin for Ethereum (aka each "MS" token is pegged 1 to 1 with the value of Ethereum). You can then use this reference to create your own by replacing parts of the code.

pragma solidity ^0.8.19

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol";

contract MyStablecoin is ERC20 {
  constructor() ERC20("MyStablecoin", "MS") {}

  function getStablecoin() public payable {
    _mint(msg.sender, msg.value);
  }

  function exchangeForEther(uint256 _amount) public {
    _burn(msg.sender, _amount);
    (bool success,) = payable(msg.sender).call{value: _amount}("");
    require(success);
  } 
}

I hope this helped

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.