Code Monkey home page Code Monkey logo

cex-deposit's Introduction

CEX Deposit

Handles incoming EOS token transfers to Centralized Exchange deposit account.

Chains

Basic Features

  • Must be eosio.token contract & EOS symbol (no fake EOS)
  • Must deposit greater then 1.0000 EOS (minimum deposit amount)
  • Must require a memo (can't be blank)
  • Create receipt transaction & add entry to table

Advanced Features

  • Memo must be all numbers (no letters)
  • Memo must be 8 digits (or whatever your internal database uses for ID's)
  • Allow incoming deposits by verrifying extended_symbol (ex: only accept eosio.token contract & EOS symbol)
  • Whitelist accounts (ex: eosio.ram & eosio.stake) to prevent all checks from incoming transfers
  • Blacklist accounts, prevent deposits from specified accounts
  • Allow to clear table row using id & trx_id params

Examples - cURL

/v1/chain/get_table_rows

curl --request POST \
  --url http://jungle.eosn.io/v1/chain/get_table_rows \
  --header 'accept: application/json' \
  --header 'content-type: application/json' \
  --data '{"code":"deposits1111","table":"incoming","scope":"deposits1111","json":true}' | jq .

output

{
  "rows": [
    {
      "id": 0,
      "from": "myaccount",
      "quantity": "1.0000 EOS",
      "memo": "foobar",
      "timestamp": "2019-11-14T17:23:45",
      "trx_id": "bf50168da5932ba0d6d7233211d946c38cfe98a71e0dfa39e6bcd48296030bb8"
    }
  ],
  "more": false,
  "next_key": ""
}

Examples - Python

import requests

url = "http://jungle.eosn.io/v1/chain/get_table_rows"

payload = "{\"code\":\"deposits1111\",\"table\":\"incoming\",\"scope\":\"deposits1111\"}"
headers = {
    'accept': "application/json",
    'content-type': "application/json"
}

response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)

Deploy contract using cleos

$ ./build.sh
$ cleos set contract <ACCOUNT> ./dist deposit.wasm deposit.abi

Add <account>@eosio.code

$ cleos set account permission <ACCOUNT> active <ACCOUNT> owner --add-code

EOSIO Smart Contract

TABLE incoming & outgoing deposits

  • {uint64_t} id - deposit id
  • {name} from - account which sent deposit
  • {asset} quantity - amount of deposit
  • {string} memo - memo used
  • {time_point_sec} timestamp - time of deposit
  • {checksum256} trx_id - transaction id

example

{
  "id": 1,
  "from": "myaccount",
  "quantity": "1.0000 EOS",
  "memo": "12345",
  "timestamp": "2019-11-14T12:00:00",
  "trx_id": "<TRANSACTION ID>",
}

ACTION receipt

Creates a receipt of incoming deposit and stores row in database

  • Authority: get_self()

params

  • {name} from - account which sent deposit
  • {asset} quantity - amount of deposit
  • {string} memo - memo used
  • {time_point_sec} timestamp - time of deposit
  • {checksum256} trx_id - transaction id

cex-deposit's People

Contributors

deniscarriere 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.