Giter Club home page Giter Club logo

agp-npm's Introduction

agp-npm

npm version

Package agp-npm is a gene parsing package for Axie Infinity.

The name agp stands for "Axie Gene Parser" which decodes the hex representation of an Axie's gene into a human readable format.

Documentation

For more detailed documentation, see agp-npm documentation.

Install

agp-npm runs on Node.js and is available as a NPM package.

npm install agp-npm

Usage

To get started, you'll first need to get the gene of an Axie in hex. You may use the Axie Infinity GraphQL endpoint to get this detail. For this example, let's use the hex 0x11c642400a028ca14a428c20cc011080c61180a0820180604233082

Let us create an AxieGene object from the hex string that we have.

JavaScript

256 Bit Genes

const { AxieGene } = require("agp-npm/dist/axie-gene"); // Defaults to HexType.Bit256
const axieGene = new AxieGene("0x11c642400a028ca14a428c20cc011080c61180a0820180604233082");

512 Bit Genes

const { AxieGene, HexType } = require("agp-npm/dist/axie-gene");
const hex = "0x280000000000010040412090830C0000000101942040440A00010190284082040001018C2061000A000101801021400400010180204080060001018418404008"
const axieGene = new AxieGene(hex, HexType.Bit512);

TypeScript

256 Bit Genes

const axieGene = new AxieGene("0x11c642400a028ca14a428c20cc011080c61180a0820180604233082");

512 Bit Genes

const hex = "0x280000000000010040412090830C0000000101942040440A00010190284082040001018C2061000A000101801021400400010180204080060001018418404008"
const axieGene = new AxieGene(hex, HexType.Bit512);

Gene Quality

You may also get the quality of the genes directly through the AxieGene object.

axieGene.getGeneQuality();

This object automatically handles the parsing of the hex value for you. You may simply use the accessors of the class to get the gene information that you want.

Here are the properties that you can get from the AxieGene object.

Go Lang Support

I also released a similar package for Go. Do check it out!

Support the Author

Love this module? Feel free to buy me a coffee and motivate me to work on more stuffs like this!

Ronin Address: ronin:789c9b253eba265f0079e3ebcaaea2503eb31bb3
ETH Address: 0x9F50E3606caf22ff5E0E03F0eb02DE3Fa2786535
Paypal: paypal.me/shanemaglangit

Support does not need to have any monetary value. I would also appreciate if you leave a star!

agp-npm's People

Contributors

alecf avatar dependabot[bot] avatar loiclaudet avatar shanemaglangit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

agp-npm's Issues

Possible typo in README.md

Under the "Usage" section in README.md

I believe it should be
const { AxieGene } = require("agp-npm/dist/axie-gene");
as opposed to
const { AxieGene } = require("agp-npm/dist/src/axie-gene");

Axie Stats

Can you add a method for obtaining Axie statistics to the library?
Interested in the fields hp, speed, morale, skill.

It seems that it is possible to summarize the information obtained from genes.
Documentation: https://axie.zone/stats

Thank you for your work.

cannot recognize part binary

Hi do you have any idea how to fix the following error shown in the screen shot?
It happens sometimes when i fetch a new list
bug

X and Y genes in the Ronin blockchain

Hello, at the moment I am analyzing the Ronin blockchain and cannot figure out how the axie body parts and genes can be decoded.

The code I ran:

import Web3 from 'web3'

const web3 = new Web3('https://api.roninchain.com/rpc')
const axieContract = new web3.eth.Contract(ABI, axieContractAddress)

axieContract.methods.axie(4950464).call().then(console.log)

RPC Response:

Result {
  '0': '4428344',
  '1': '4505689',
  '2': '1629870871',
  '3': [
    '14474011154664526034939695189344445127921630876185289334580322480553868674050',
    '1766957471863971104923304451713139065230110618240613685279804305648419844',
    x: '14474011154664526034939695189344445127921630876185289334580322480553868674050',
    y: '1766957471863971104923304451713139065230110618240613685279804305648419844'
  ],
  '4': '2',
  '5': '0',
  sireId: '4428344',
  matronId: '4505689',
  birthDate: '1629870871',
  genes: [
    '14474011154664526034939695189344445127921630876185289334580322480553868674050',
    '1766957471863971104923304451713139065230110618240613685279804305648419844',
    x: '14474011154664526034939695189344445127921630876185289334580322480553868674050',
    y: '1766957471863971104923304451713139065230110618240613685279804305648419844'
  ],
  breedCount: '2',
  level: '0'
}

Can your library help me get genes for the genes.x and genes.y I have?
Do you have any idea how to convert this to the SHA hash your library needs?

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.