Git Product home page Git Product logo

utility-contracts's Introduction

utility-contracts

smart contracts which can be used as utility contracts to interact with the blockchain

Mainnet deployment

PublicTokens: 0x202549FCF4Cc855ACA456c39A839c4f202Ee5Cef

TokenBalances: 0x2783c0A4Bfd3721961653a9e9939Fc63687bf07f

Ropsten deployment

PublicTokens: 0xf166098CBA584b3Ebf9B5014Dca4009E89F4485d

TokenBalances: 0xB8E1Bbc50FD87Ea00D8ce73747Ac6F516aF26dAC

Example to read all token balances

const Web3 = require("web3");
const hexDecoder = require("./libs/binaryDecoder");
const web3 = new Web3("https://api.myetherwallet.com/eth");
const abi = [
  {
    constant: true,
    inputs: [
      {
        name: "_owner",
        type: "address"
      },
      {
        name: "name",
        type: "bool"
      },
      {
        name: "website",
        type: "bool"
      },
      {
        name: "email",
        type: "bool"
      },
      {
        name: "_count",
        type: "uint256"
      }
    ],
    name: "getAllBalance",
    outputs: [
      {
        name: "",
        type: "bytes"
      }
    ],
    payable: false,
    stateMutability: "view",
    type: "function"
  }
];
const balanceContract = new web3.eth.Contract(
  abi,
  "0xdAFf2b3BdC710EB33A847CCb30A24789c0Ef9c5b"
);
balanceContract.methods
  .getAllBalance(
    "0xDECAF9CD2367cdbb726E904cD6397eDFcAe6068D",
    true,
    true,
    true,
    0
  )
  .call()
  .then(res => {
    console.log(hexDecoder.decode(res));
  });

Output

[ { symbol: '$TEAK',
    addr: '0x7dd7f56d697cc0f2b52bd55c057f378f1fe6ab4b',
    decimals: 18,
    balance: '0',
    name: '$TEAK',
    website: 'https://steak.network',
    email: '[email protected]' },
  { symbol: 'DIVX',
    addr: '0x13f11c9905a08ca76e3e853be63d4f0944326c72',
    decimals: 18,
    balance: '0',
    name: 'DIVX',
    website: 'https://www.diviproject.org',
    email: '[email protected]' }, ...

utility-contracts's People

Contributors

gamalielhere avatar gesseekur avatar kvhnuke 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.