Socket
Socket
Sign inDemoInstall

@axie-taxi/ethers-js

Package Overview
Dependencies
47
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @axie-taxi/ethers-js

AxieTaxi Ronin Contract API for ethers providers


Version published
Maintainers
1
Created

Readme

Source

@axie-taxi/ethers-js

What is this?

These are the axie infinity contracts (slp, axies) that are bound to the AxieTaxiProvider and allow you to make write or read requests to the chain. They are made available to you through the useAxieTaxi hook.

Installation and usage

import { AxieTaxi } from "@axie-taxi/core";
import { instantiateContracts } from "@axie-taxi/ethers-js";
import React from "react";
import ReactDOM from "react-dom";
import App from "./App";
import "./index.css";

ReactDOM.render(
  <React.StrictMode>
    <AxieTaxi apiKey={"testAPIKey"} contracts={instantiateContracts}>
      <App />
    </AxieTaxi>
  </React.StrictMode>,
  document.getElementById("root")
);

In the app

export default function App() {
  const {
    account,
    connect,
    deactivate,
    linkSession,
    library,
    sessionKey,
    contracts,
    auth,
  } = useAxieTaxi<Contracts>();

  const axieContract = contracts?.axieContract;
  const [ownedAxies, setOwnedAxies] = useState<BigNumber>(BigNumber.from(0));

  const getOwnedAxies = useCallback(async () => {
    if (!account) {
      return BigNumber.from(0);
    } else if (!axieContract) {
      return BigNumber.from(0);
    }
    const owned = await axieContract.balanceOf(account);
    if (owned) {
      return owned;
    } else {
      return BigNumber.from(0);
    }
  }, [account, axieContract]);

  useEffect(() => {
    (async () => {
        setOwnedAxies(await getOwnedAxies());
    })();
  }, [account, axieContract, getOwnedAxies]);

  return <div>{ownedAxies.toString()}</div>;
}

Keywords

FAQs

Last updated on 31 Dec 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc