Giter Club home page Giter Club logo

contract_spending_cusd's Introduction

Spending cUSD from another Solidity Contract

Simple app to demo how to use a contract to spend cUSD on a users behalf.

Spending cUSD on behalf of users

This example demonstrates how a contract can be designed to spend cUSD for a user. View the simple contract in ./contracts/cUSD_spender.sol. This contract is too simple to be useful, but demonstrates the necessary concepts, namely how to access the cUSD contract from another Solidity contract.

Before the cUSD_spender contract can spend cUSD on behalf of a user, the user must approve the contract to spend cUSD for them. The ./webpage directory shows how you can do this. Essentially, in the UI the dapp will request a transaction from the user, to the cUSD contract, calling the approve function for the desired amount. Once the approve transaction is confirmed, the dapp can request to send cUSD from the user's account.

Get Started

  1. Run yarn install in the project root.
  2. Run node createAccount.js. This will print new Celo account details. Copy the private key for your new account into the PRIVATE_KEY variable in .env.
  3. Fund the account address on the Alfajores testnet here: https://celo.org/developers/faucet
  4. Deploy your own cUSD_spender contract to the Alfajores testnet with truffle migrate --network alfajores
  5. Move into the ./webage directory. Run yarn to install the dependencies.
  6. Run the web server with yarn dev.

contract_spending_cusd's People

Contributors

critesjosh avatar

Stargazers

Allan Okoth avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.