{"_id":"@depay/web3-tokens-svm","_rev":"2-eb3a03ece41463ad53c316977dc333a9","name":"@depay/web3-tokens-svm","dist-tags":{"latest":"11.1.0"},"versions":{"11.0.0":{"name":"@depay/web3-tokens-svm","version":"11.0.0","keywords":["token","cryptocurrencies","web3","blockchains"],"author":{"name":"depay.com"},"license":"MIT","_id":"@depay/web3-tokens-svm@11.0.0","maintainers":[{"name":"depay-sebastian","email":"s@depay.fi"},{"name":"0xneo11","email":"0xneo11@gmail.com"}],"homepage":"https://depay.com","bugs":{"url":"https://github.com/DePayFi/web3-tokens/issues"},"dist":{"shasum":"2644341c62875ef7b10c55df3c8e80f436a2245e","tarball":"https://registry.npmjs.org/@depay/web3-tokens-svm/-/web3-tokens-svm-11.0.0.tgz","fileCount":9,"integrity":"sha512-4EcGUafrLMY/TTb/bnS79ERzDrQI8CQXbcQi+mYCnjcmPLL73PB5TaAYraq6TMt5eWXtw5sONP8f32g3c+levg==","signatures":[{"sig":"MEUCIQCF3SRsyOEIbXdHK3HBANjbvV0OFyMl6tV6rdsW2GrURQIgU45WFqoN+yD6Md3QoDuSvrJEK1UeWo31sixbMzlDl28=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":214189},"main":"dist/umd/index.svm.js","module":"dist/esm/index.svm.js","engines":{"node":">=16"},"gitHead":"8ad23e0bf1a63309a6f5795ef774507e70044cc6","private":false,"_npmUser":{"name":"depay-sebastian","email":"s@depay.fi"},"moduleName":"Web3Tokens","repository":{"url":"git+ssh://git@github.com/DePayFi/web3-tokens.git","type":"git"},"_npmVersion":"8.19.4","description":"JavaScript library providing basic functionalities to interact with web3 tokens.","directories":{},"_nodeVersion":"16.20.2","dependencies":{},"_hasShrinkwrap":false,"peerDependencies":{"ethers":"^5.7.1","@depay/solana-web3.js":"^1.98.0","@depay/web3-client-svm":"^11.0.1","@depay/web3-blockchains":"^9.7.9"},"_npmOperationalInternal":{"tmp":"tmp/web3-tokens-svm_11.0.0_1742116462826_0.9939294767323421","host":"s3://npm-registry-packages-npm-production"}},"11.1.0":{"name":"@depay/web3-tokens-svm","moduleName":"Web3Tokens","version":"11.1.0","description":"JavaScript library providing basic functionalities to interact with web3 tokens.","main":"dist/umd/index.svm.js","module":"dist/esm/index.svm.js","repository":{"type":"git","url":"git+ssh://git@github.com/DePayFi/web3-tokens.git"},"keywords":["token","cryptocurrencies","web3","blockchains"],"author":{"name":"depay.com"},"license":"MIT","bugs":{"url":"https://github.com/DePayFi/web3-tokens/issues"},"homepage":"https://depay.com","private":false,"dependencies":{},"peerDependencies":{"@depay/solana-web3.js":"^1.98.0","@depay/web3-blockchains":"^9.7.9","@depay/web3-client-svm":"^11.0.1","ethers":"^5.7.1"},"engines":{"node":">=16"},"gitHead":"3ac8d41607333d5e1551bf4e816c5bb1ed480e17","_id":"@depay/web3-tokens-svm@11.1.0","_nodeVersion":"16.20.2","_npmVersion":"8.19.4","dist":{"integrity":"sha512-3D9xe/Jw8Z3lXU7d0WQSJ2jnGqKCoBV/44ajGIrgC1r+1apw9eVS0GU/5MhRqFI4wvhewyk84FoViia5cvO0lw==","shasum":"2112b161398098bdcbc4fee8fd0aa7819c4eb631","tarball":"https://registry.npmjs.org/@depay/web3-tokens-svm/-/web3-tokens-svm-11.1.0.tgz","fileCount":9,"unpackedSize":217241,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIBobJusZr1IOVJHrIAiecBrnkFzGyRPY4Qk3Xb6ZUjzyAiAIGs1lUkwXVApVAwaUgoxhrmk5O9qBZ6AvH07BvCqQdg=="}]},"_npmUser":{"name":"depay-sebastian","email":"s@depay.fi"},"directories":{},"maintainers":[{"name":"depay-sebastian","email":"s@depay.fi"},{"name":"0xneo11","email":"0xneo11@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/web3-tokens-svm_11.1.0_1744901524469_0.2244607760721573"},"_hasShrinkwrap":false}},"time":{"created":"2025-03-16T09:14:22.742Z","modified":"2025-04-17T14:52:04.883Z","11.0.0":"2025-03-16T09:14:23.018Z","11.1.0":"2025-04-17T14:52:04.671Z"},"bugs":{"url":"https://github.com/DePayFi/web3-tokens/issues"},"author":{"name":"depay.com"},"license":"MIT","homepage":"https://depay.com","keywords":["token","cryptocurrencies","web3","blockchains"],"repository":{"type":"git","url":"git+ssh://git@github.com/DePayFi/web3-tokens.git"},"description":"JavaScript library providing basic functionalities to interact with web3 tokens.","maintainers":[{"name":"depay-sebastian","email":"s@depay.fi"},{"name":"0xneo11","email":"0xneo11@gmail.com"}],"readme":"## Quickstart\n\n```\nyarn add @depay/web3-tokens\n```\n\nor \n\n```\nnpm install --save @depay/web3-tokens\n```\n\n```javascript\nimport Token from '@depay/web3-tokens'\n\nlet token = new Token({\n  blockchain: 'ethereum',\n  address: '0xa0bed124a09ac2bd941b10349d8d224fe3c955eb'\n});\n\ntoken.address // '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb'\nawait token.decimals() // 18\nawait token.symbol() // 'DEPAY'\nawait token.name() // 'DePay'\n```\n\n## Support\n\nThis library supports the following blockchains:\n\n- [Ethereum](https://ethereum.org)\n- [BNB Smart Chain](https://www.binance.org/smartChain)\n- [Polygon](https://polygon.technology)\n- [Solana](https://solana.com)\n- [Fantom](https://fantom.foundation)\n- [Arbitrum](https://arbitrum.io)\n- [Avalanche](https://www.avax.network)\n- [Gnosis](https://gnosis.io)\n- [Optimism](https://www.optimism.io)\n- [Base](https://base.org)\n- [Worldchain](https://worldcoin.org/world-chain)\n\n## Platform specific packaging\n\nIn case you want to use and package only specific platforms, use platform-specific packages:\n\n### EVM (Ethereum Virtual Machine) specific packaging\n\n```javascript\nimport Token from '@depay/web3-tokens-evm'\n```\n\n### SVM (Solana Virtual Machine) specific packaging\n\n```javascript\nimport Token from '@depay/web3-tokens-solana'\n```\n\n## Functionalities\n\n### initalize (new)\n\n```javascript\nimport Token from '@depay/web3-tokens'\n\nlet token = new Token({\n  blockchain: 'ethereum',\n  address: '0xa0bed124a09ac2bd941b10349d8d224fe3c955eb'\n});\n```\n\n### decimals\n\nRetrieves token decimals\n\n```javascript\nawait token.decimals() // 18\n```\n\n### symbol\n\nRetrieves token symbol\n\n```javascript\nawait token.symbol() // DEPAY\n```\n\n### name\n\nRetrieves token name\n\n```javascript\nawait token.name() // DePay\n```\n\n### name for NFT by id\n\nRetrieves token name for token address by NFT id:\n\n```javascript\nawait token.name({ id: '42745998150656004690816543961586238000273307462307754421658803578179357246440' }) // NFT Butler Lifetime License\n```\n\n### balance\n\nProvides the balance (BigNumber) of the given account:\n\n```javascript\nawait token.balance('0xb0252f13850a4823706607524de0b146820F2240') // BigNumber {_hex: \"0x0b896d5e9eeaabf4f1\", _isBigNumber: true}\n```\n\nthis also works for the native token of the given blockchain:\n\n```javascript\nlet token = new Token({ ..., address: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE' })\nawait token.balance('0xb0252f13850a4823706607524de0b146820F2240') // BigNumber {_hex: \"0x0b896d5e9eeaabf4f1\", _isBigNumber: true}\n```\n\n#### balance for NFTs (by id)\n\nIf you pass a second parameter, it will be used to get the balance for the given account for the given token id:\n\n```javascript\nawait token.balance('0xb0252f13850a4823706607524de0b146820F2240', '42745998150656004690816543961586238000273307462307754421658803578179357246440')\n```\n\n### BigNumber\n\nProvides the BigNumber amount for a given token (based on the tokens decimals) based on a human readable amount:\n\n```javascript\nlet token = new Token({\n  blockchain: 'ethereum',\n  address: '0xa0bed124a09ac2bd941b10349d8d224fe3c955eb'\n}) \n\nawait token.BigNumber(1) // BigNumber '1000000000000000000'\n```\n\n```javascript\nawait Token.BigNumber({\n  amount: 1,\n  blockchain: 'ethereum',\n  address: '0xa0bed124a09ac2bd941b10349d8d224fe3c955eb'\n}) // BigNumber '1000000000000000000'\n```\n\n### readable\n\nProvides a human readable amount based on a given BigInt number.\n\n- Ending zeros will be eliminated `1.30000` -> `1.3`\n\n- Decimals are dropped if there are none `1.00000` -> `1`\n\n```javascript\nawait Token.readable({\n  amount: '1231211111210000000',\n  blockchain: 'ethereum',\n  address: '0xa0bed124a09ac2bd941b10349d8d224fe3c955eb'\n}) // \"1.23121111121\"\n```\n\n```javascript\nlet token = new Token({\n  blockchain: 'ethereum',\n  address: '0xa0bed124a09ac2bd941b10349d8d224fe3c955eb'\n})\n\nawait token.readable('1231211111210000000') // \"1.23121111121\"\n```\n\n### Token Standards\n\n#### EVM: Token Standards\n\n```javascript\nimport Token from '@depay/web3-tokens'\n\nToken.ethereum['20'] // [...] <XYZ>20 standard\nToken.bsc['20'] // [...] <XYZ>20 standard\n\nToken.ethereum.ERC20 // [...] ERC20 ABI\nToken.bsc.BEP20 // [...] BEP20 ABI\n\nToken.ethereum.WRAPPED // [...] WETH ABI\nToken.bsc.WRAPPED // [...] WETH ABI\n\n```\n\n`DEFAULT` references the broad default token standard on the respective blockchain:\n\n```javascript\nimport Token from '@depay/web3-tokens'\n\nToken.ethereum.DEFAULT // ERC20\nToken.bsc.DEFAULT // BEP20\n\nToken[blockchain].DEFAULT\n```\n\n#### Solana: Token Standards, Constants, Layouts and helper methods\n\n```javascript\nimport Token from '@depay/web3-tokens'\n\nToken.solana\n// MINT_LAYOUT,\n// METADATA_LAYOUT,\n// TRANSFER_LAYOUT,\n// METADATA_ACCOUNT,\n// TOKEN_PROGRAM,\n// ASSOCIATED_TOKEN_PROGRAM,\n// findProgramAddress({ token, owner })\n// findAccount({ token, owner })\n// async createTransferInstruction({ token, amount, from, to })\n// async createAssociatedTokenAccountInstruction({ token, owner, payer })\n// initializeAccountInstruction({ account, token, owner })\n// closeAccountInstruction({ account, owner })\n// getMetaData\n// getMetaDataPDA\n```\n\n## Development\n\n### Get started\n\n```\nyarn install\nyarn dev\n```\n\n### Release\n\n```\nnpm publish\n```\n","readmeFilename":"README.md"}