npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@punkcodeprotocol/sdk

v0.0.1

Published

Punkcode Labs. Dynamic NFT protocol.

Readme

🚀 MetaToken SDK

[TOC]

📌 Overview

📥 Installation & Setup

npm i metatoken_sdk

📝 How to use MetaTokenSDK? Refer to this example

1. Deploy your Avatar and Weapon

import { MetaTokenDeployer } from "metatoken_sdk";
const ethProvider = ethers.getDefaultProvider("goerli"); // goerli testnet 
const signer = new ethers.Wallet(key, provider);

// deploy your Avatar
let deployTx = await MetaTokenContract.deployDefault({
    chainId: chainId,
    runner: signer,
    name: "Avatar",
    symbol: "AV",
});
const avatarContract = deployTx.metaTokenContract;

// deploy your Weapon
deployTx = await MetaTokenContract.deployDefault({
    chainId: chainId,
    runner: signer,
    name: "Weapon",
    symbol: "WP",
});
const weaponContract = deployTx.metaTokenContract;

|Function| Parameter | Parameter Description | type | |---| --------------------------------------- | --------- |-----| |deployDefault| signer | ethers signer | signer | || chainId | chainId of network |number| || name | the name of MetaToken |string| || symbol | the symbol of MetaToken |String|

2. Deploy your PropertyFactory

deployTx = await PropertyFactory.deployDefault({
    chainId: chainId,
    runner: signer,
    name: "PropertyFactory",
    uri: "<propertyURI>",    
});
const propertyFactoryContract = deploy.propertyFactory;

|Function| Parameter | Description | type | |---| --------------------------------------- | --------- |-----| |deployDefault| signer | ethers signer | signer | || chainId | chainId of network |number| || name | the name of MetaToken |string| || uri | the uri of MetaToken |string|

3. Mint MetaToken and construct.

const mintAvatarTx = await avatarContract.mint({to: "<to_address>"});
// first avatar
const avatar00 = new MetaToken({
    tokenAddress: avatarContract.tokenAddress,
    tokenId: mintTx.metaTokenId,
    chainId: chainId,
    signer: signer,
});

const mintWeaponTx = await avatarContract.mint({to: await avatar00.getTokenBoundAccount()});
// first weapon
const weapon00 = new new MetaToken({
    tokenAddress: weaponContract.tokenAddress,
    tokenId: mintWeaponTx.metaTokenId,
    chainId: chainId,
    signer: signer,
});

| Function | Parameter | Parameter Description | type | | --------------------------------------- | --------- |-----| --------------------------------------- | | mint | to | the address of someone you want to send | String |

|Function| Parameter | Parameter Description | type | |---| --------------------------------------- | --------- |-----| |construct| tokenAddress | the address of MetaToken | string | || tokenId | the id of MetaToken you mint | number | || chainId | chainId | number | || signer | ethers signer | signer |

4. Setup EventUp & EventDown.

Metatoken can only add tokens from the eventup, and Metatoken can only be added by tokens from the eventdown list

const setEventsUpTx = await avatar00.getContract().connect(signer).setEventsUp({eventUps:['<weaponTokenAddress>']})
const setEventsDownTx = await weapon00.getContract().connect(signer).setEventsDown({eventDowns:['<avatarTokenAddress>']})

|Function| Parameter | Parameter Description | type | |---| --------------------------------------- | --------- |-----| |setEventsUp| eventUps | list of address you want the MetaToken can be added | list | |setEventsDown| eventDowns | list of address you want the MetaToken can add | list |

5. Control your Weapon with your Avatar

You can add weapon, remove weapon, replace them.

[Note] Make sure your Avatar's TokenBoundAccount owns the Weapon

// you can add child for your token
await avatar00.addChild({
    childToken: {
        tokenAddress: weapon.tokenAddress,
        tokenId: weapon.tokenId,
    },
});
// you can serach your childs
await avatar00.getChilds(); 
// you can search your parent
await weapon00.getParent();
// you can remove child for your token
await avatar00.removeChild({
    waitRemoveChildTokenIndex: 0,
})
// you can replace child for your token
await avatar00.batchReplaceChild({
    waitAddChildTokens: [
        {
            tokenAddress: "<WeaponAddress>",
            tokenId: "<anotherTokenId>",
        },
    ],
    waitRemoveChildTokenIndex: [0],
});

|Structure|Parameter| Parameter Description | Type| |--| --------------------------------------- | --------- |-----| | childToken/waitAddChildTokens | tokenAddress | Token address | address | | | tokenId | Token id | int |

|Function| Parameter | Parameter Description | |--| --------------------------------------- | --------- | |addChild| childToken | token info you want to add | |removeChild| waitRemoveChildTokenIndex | index of token you want to remove from MetaToken | |batchReplaceChild| waitAddChildTokens | token info list you want to add | || waitRemoveChildTokenIndex | index of token you want to remove from MetaToken | |getChilds| | | |getParent| | |

7. Setup global property

This function is used to configure global properties, as example, we configure "ATTACK" and "Defend" as our default properties.

// add global property (Attack and Defend)
await propertyFactoryContract.addGlobalProperty({property:["ATK", "DEF"]});
console.log(await propertyFactoryContract.queryGlobalProperty());
// output: [ 'ATK', 'DEF' ]

|Function| Parameter | Parameter Description | Type | |--| --------------------------------------- | --------- | ---| |addGlobalProperty| property | property list | list |

8. Register PropertyFactory for your Avatar and Weapon

By register PropertyFactory for your MetaToken, you can manage the properties available for Metatoken with the PropertyFactory.

// register avatar
await avatarContract.setUpPropertyFactory({
    factoryAddress: propertyFactoryContract.implementationAddress,
});
// register weapon
await weaponContract.setUpPropertyFactory({
    factoryAddress: propertyFactoryContract.implementationAddress,
});

|Function| Parameter | Parameter Description | Type | |--| --------------------------------------- | --------- | ---| |setUpPropertyFactory| factoryAddress | property factory implement address | string |

9. Setup Avatar's property and Weapon's property

Configure the properties available for Metatoken.

// add atk and def for avatar
await propertyFactoryContract.setPropertyFor({
    tokenAddress: avatar.tokenAddress,
    propertyIndex: [0, 1],
});
// add atk for avatar
await propertyFactoryContract.setPropertyFor({
    tokenAddress: weapon.tokenAddress,
    propertyIndex: [0],
});

|Function| Parameter | Parameter Description | Type | |--| --------------------------------------- | --------- | ---| |setPropertyFor| tokenAddress | MetaToken implement address | string | | | propertyIndex | index of property | list |

10. Mint property for your Avatar and Weapon

// add 100 atk to avatar
await propertyFactoryContract.mintProperty({
    to: (await avatar00.getTokenBoundAccount()).address,
    propertyIndex: 0,
    amount: 100,
    data: "0x",
});
// add 50 def to avatar
await propertyFactoryContract.mintProperty({
    to: (await avatar00.getTokenBoundAccount()).address,
    propertyIndex: 1,
    amount: 100,
    data: "0x",
});
// add 45 atk to weapon
await propertyFactoryContract.mintProperty({
    to: (await weapon00.getTokenBoundAccount()).address,
    propertyIndex: 0,
    amount: 100,
    data: "0x",
});

|Function| Parameter | Parameter Description | Type | |--| --------------------------------------- | --------- | ---| |mintProperty| to | to address | string | | | propertyIndex | index of property | number | | | amount | amount | number | | | data(optional) | call data | hex string |

11. Now you can search your Avatar's property and Weapon's property

await propertyFactoryContract.propertiesOf({ tokenAddress: avatar00.tokenAddress, tokenId:0 }),
await propertyFactoryContract.propertiesOf({ tokenAddress: weapon00.tokenAddress }),

|Function| Parameter | Parameter Description | Type | |--| --------------------------------------- | --------- | ---| |propertiesOf| tokenAddress | tokenAddress | string | | | tokenId(optional) | tokenId | number |

12. We also support ERC6551

You can learn how to use TokenBound here.