# Gold-backed ERC-1155 The idea is to create an ERC-1155 that is backed by gold, i.e. the owner can redeem it for DGX tokens. ## Motivation If one can redeem an ERC-1155 token for a fixed amount of gold (DGX), the minimum price of this unique asset is garanteed for ever (so to speak). ## Workflow 1. Alice mint an ERC-1155 2. She deploys a DGX vending machine 3. In the ERC-1155 metadata, she adds: * the address of the vending machine * the JS call to check if the DGXs are available OR redeemed (vending machine contract's `status` function) ## Roadmap 1. Create an ERC-20 vending machine 2. Create an ERC-1155 vending machine 3. Provide a process to add the vending machine contract address in the ERC-1155 metadata ## The ERC-20 vending machine We can imagine: * a **very** sexy (and fun) UI that looks like a physical vending machine. * an optional cut for the dev that were able to implement it. ;) * a full tutorial following the [MST tutorial](https://github.com/julienbrg/my-stupid-token), knowing that education is an important part of the overall adoption of Ethereum. ### Contract ```javascript=16 pragma solidity ^0.5.0; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/math/SafeMath.sol"; contract VendingMachine is ownable() { /** * 'Activate' ERC20 DAILLE + 'Activate' ERC20 MST */ uint public balance // amount of token for sale uint public rate // set at deployment uint public duration // set at deployment constructor() internal { /** * msg.sender becomes the owner * Set balance * Set rate * Set duration */ } function buy(amount) public { /** * We want to: * If it's any other thing than DAI, revert * If duration is not valid, revert * Calculate the amount of MST to send (received amount of DAI * the rate) * Is it superior to balance? If yes, revert * Send the amount of MST to msg.sender * Create an event */ require(DAILLE.transferFrom(msg.sender,target,amount * rate)); require(MST.transfer(msg.sender,amount)); emit Event(); } function collect(col) public { require(msg.sender=owner); /** * Send col to msg.sender */ } function end() public { require(msg.sender=owner); /** * If the duration is valid, revert * Send both DAILLE and MST to owner */ } } ``` ## The ERC-1155 vending machine ### Requirements An ERC-1155 version of the the ERC-20 vending machine. Instead of an ERC-20 token, the owner sells a fixed quantity of ERC-20 token for one specific ERC-1155 (i.e. "I sell this NFT for 1 DGX"). ### Contract ``` ``` ## The Gold-backed ERC-1155 ### Requirements ### Contract ``` ``` ## Resources * The NFT Bible: https://opensea.io/blog/guides/non-fungible-tokens/amp/ * The ERC-1155 (by [Enjin](http://enjin.io/)): https://blog.enjincoin.io/erc-1155-the-final-token-standard-on-ethereum-a83fce9f5714