Code Monkey home page Code Monkey logo

hacktherainbow's Introduction

El Dorado - Hack the Rainbow ๐ŸŒˆ

ElDoradoSubmission

Objective

Integrate El Dorado with Near so the users enjoy a fast, reliable, and accessible blockchain stable-coin account.

Relevant Links

This repo contains:

  • /near-contract:
    • A token implementation put together from several examples
    • Roughtly-put-together UI to manage said contract: Claim, Mint, and Send tokens. (NOTE: this is not intented to be used by users)
  • /eldoardo-near-client:
    • An npm client library that El Dorado uses in our backend to communciate to the token contract
    • A very basic (NOT READY FOR PRODUCTION) implementation of a KeyStore that uses AWS DynamoDB as storage.

Dev Environment

If you want to develop on this repo, the only thing you'd need is Docker, VSCode, and this extension.

After opening it in vscode you'll be prompted to re-open it in a Container. Press Reopen in container. if not prompted, can also press Ctrl+Shift+p and type Reopen in container and select that item from the command bar.

All the tooling, SDKs, and a local dynamodb image will be ready for you!!

High-level implementation and Status

  • All Near tokens funds are backed in a common ETH address owned by El Dorado
  • As soon as funds are final, we mint them on our contract using the rainbow bridge (Pending) (LOCK FUNDS)
  • A simple contract for tokens in near
  • Interface to near token contract to be able to make transfers between El Dorado users using the app
  • Integrate Near into our backend
  • When users buy crypto with card, send the funds to lockable address
    • Because of the bridge not being ready we send the near tokens to the user after purchasing crypto without any "proof"

How to test the submission

NOTE: This might not work on a MAC due to docker networking

Environment

First follow the Dev Environment guide above to get everything ready, without this the library will not work without additional setup and configuration.

Run the contract

NOTE: The first time yarn installs the node modules, it might fail, just do it again and you'll be fine.

cd near-contract
yarn
yarn dev

The command will fail at the end because it cannot open the browser (you are in a container), but worry not, just click the url shown in the terminal and it will open it for you. This tunels the port from the container to your host, so you can connect to it.

It will show you that you've got 0 tokens, and there are 0 tokens in supply.

Contract ownership and supply

NOTE: If you want the account of the contract and the owner to be different (we call it merchant account) then you need to near login with the same account you claim the token.

Once you get to the site click on CLAIM to get ownership of the contract if you haven't done so. Because our bridge PoC did not work, (our team worked in parallel) we can use the Mint button to get some tokens to the owner (merchant account).

Contract and Account Id

Copy down the Contract Id and Account Id for later.

Make sure the dev credentials from the near-contract deployment are stored in /home/gitpod/.near-credentials.

The Npm library have an integration test that works with the contract

To run the library run the following command:

yarn
CONTRACT_NAME=<ContractName> MASTER_ACCOUNT=<AccountName> yarn test

Those credentials CONTRACT_NAME & MASTER_ACCOUNT will be saved to your local DynamoDb to be used by the test later on.

There are two integration tests:

  • Wallet: It creates a user and makes sure that the keypair is stored in dynamo and can be retrieved.
  • Transfer:
    • Two users are created.
    • Fund user A with 5 tokens.
    • Use the transferFrom function to send 1 token from A to B using the merchat account (with allowance).

hacktherainbow's People

Contributors

andreujuanc avatar

Stargazers

Ben Sayeg 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.