Giter Club home page Giter Club logo

helpful-js's Introduction

helpful-js

Helpful javascript code snippets to help people wanted to read and interacts with javascript contracts

helpful-js's People

Contributors

codingshot avatar heroes-bounty[bot] avatar m-rb3 avatar

helpful-js's Issues

create for donating an amount of a fungible token

  • select address of fungible token or NFT
  • if nft, number of poeple will be based on number of nfts selected
  • select number of people to send to
  • select where list is coming from, donors fo approved projects or approved projects
  • select wieghts, need to have a percentage for each donor that was selected

Need this for bos component

create for number of stamp

show total number of stamp

reference code here (from nada.bot home page)

`
import { useState, useEffect } from "react";
import Big from "big.js";
import * as nearAPI from "near-api-js";

const { keyStores, connect, Contract } = nearAPI;

const Status = () => {
const [statsData, setStatsData] = useState({
verified_providers: "-",
total_checks: "-",
verified_humans: "-",
});
useEffect(() => {
(async function () {
const myKeyStore = new keyStores.InMemoryKeyStore();

  const connectionConfig = {
    networkId: "mainnet",
    keyStore: myKeyStore,
    nodeUrl: "https://rpc.mainnet.near.org",
    walletUrl: "https://wallet.mainnet.near.org",
    helperUrl: "https://helper.mainnet.near.org",
    explorerUrl: "https://explorer.mainnet.near.org",
  };

  // connect to NEAR
  const nearConnection = await connect(connectionConfig);
  const account = await nearConnection.account();
  const contract = new Contract(account, "v1.nadabot.near", {
    viewMethods: ["get_providers", "get_users_for_stamp", "is_human"],
  });

  //   get Active Provdiers
  const activeProviders = await contract.get_providers({
    status: "Active",
  });

  //   get Total Checks
  const providers = await contract.get_providers();
  let totalStamps = 0;
  providers.forEach((provider) => (totalStamps += provider.stamp_count));

  //   get Humans Verified

  // Get All Users
  let totalUsers = [];
  for (const provider of providers) {
    const users = await contract.get_users_for_stamp({
      provider_id: provider.provider_id,
    });
    totalUsers.push(...users);
  }
  totalUsers = [...new Set(totalUsers)];
  // Verify Users
  let humanVerified = 0;
  for (const user of totalUsers) {
    const isHuman = await contract.is_human({
      account_id: user,
    });
    if (isHuman) humanVerified += 1;
  }

  const statsData = {
    verified_providers: activeProviders.length,
    total_checks: totalStamps,
    verified_humans: humanVerified,
  };
  setStatsData(statsData);
})();

}, []);
return (





{statsData.verified_humans}

Humans Verified




{statsData.verified_providers}

Verified Providers




{statsData.total_checks}

Total Checks




);
};

export default Status;
`

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.