
Security News
PodRocket Podcast: Inside the Recent npm Supply Chain Attacks
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
@depay/web3-assets
Advanced tools
JavaScript library to retrieve Web3 assets of a given or connected wallet/account.
yarn add @depay/web3-assets
or
npm install --save @depay/web3-assets
import { getAssets } from '@depay/web3-assets'
let assets = await getAssets({
accounts: {
ethereum: '0x08B277154218CCF3380CAE48d630DA13462E3950',
bsc: '0x08B277154218CCF3380CAE48d630DA13462E3950'
}
})
//[
// {
// "name": "Dai Stablecoin",
// "symbol": "DAI",
// "address": "0x6B175474E89094C44Da98b954EedeAC495271d0F",
// "blockchain": "ethereum",
// "type": "20",
// "balance": "8007804249707967889272"
// }, {
// "name": "DePay",
// "symbol": "DEPAY",
// "address": "0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb",
// "blockchain": "ethereum",
// "type": "20",
// "balance": "212816860003097638129"
// }, {
// "name": "PancakeSwap Token",
// "symbol": "CAKE",
// "address": "0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82",
// "blockchain": "bsc",
// "type": "20",
// "balance": "2221112213212321"
// }
//]
import { dripAssets } from '@depay/web3-assets'
let allAssets = await dripAssets({
accounts: { ethereum: '0x08B277154218CCF3380CAE48d630DA13462E3950', bsc: '0x08B277154218CCF3380CAE48d630DA13462E3950' },
priority: [
{ blockchain: 'ethereum', address: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb' },
{ blockchain: 'bsc', address: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb' },
{ blockchain: 'ethereum', address: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2' },
{ blockchain: 'bsc', address: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c' }
],
drip: (asset)=>{
// {
// "name": "DePay",
// "symbol": "DEPAY",
// "address": "0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb",
// "blockchain": "ethereum",
// "type": "20",
// "balance": "212816860003097638129"
// }
}
})
This library supports the following blockchains:
In case you want to use and package only specific platforms, use the platform-specific package:
import { getAssets } from '@depay/web3-assets-evm'
import { getAssets } from '@depay/web3-assets-svm'
Retrieves all assets of the given account on the given blockchains:
import { getAssets } from '@depay/web3-assets'
let assets = await getAssets({
accounts: {
ethereum: '0x08B277154218CCF3380CAE48d630DA13462E3950',
bsc: '0x08B277154218CCF3380CAE48d630DA13462E3950'
}
})
//[
// {
// "name": "Dai Stablecoin",
// "symbol": "DAI",
// "address": "0x6B175474E89094C44Da98b954EedeAC495271d0F",
// "blockchain": "ethereum",
// "type": "20",
// "balance": "8007804249707967889272"
// }, {
// "name": "DePay",
// "symbol": "DEPAY",
// "address": "0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb",
// "blockchain": "ethereum",
// "type": "20",
// "balance": "212816860003097638129"
// }, {
// "name": "PancakeSwap Token",
// "symbol": "CAKE",
// "address": "0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82",
// "blockchain": "bsc",
// "type": "20",
// "balance": "2221112213212321"
// }
//]
Timeout happens after 10s and []
will be returned in cases the assets for the given addresses can't be retrieved within 10s.
Only gets assets and balances for given token addresses.
import { getAssets } from '@depay/web3-assets'
let assets = await getAssets({
accounts: {
ethereum: '0x08B277154218CCF3380CAE48d630DA13462E3950',
bsc: '0x08B277154218CCF3380CAE48d630DA13462E3950'
},
only: {
ethereum: ['0x6B175474E89094C44Da98b954EedeAC495271d0F'],
bsc: ['0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82']
}
})
//[
// {
// "name": "Dai Stablecoin",
// "symbol": "DAI",
// "address": "0x6B175474E89094C44Da98b954EedeAC495271d0F",
// "blockchain": "ethereum",
// "type": "20",
// "balance": "8007804249707967889272"
// }, {
// "name": "PancakeSwap Token",
// "symbol": "CAKE",
// "address": "0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82",
// "blockchain": "bsc",
// "type": "20",
// "balance": "2221112213212321"
// }
//]
Excludes given assets
import { getAssets } from '@depay/web3-assets'
let assets = await getAssets({
accounts: {
ethereum: '0x08B277154218CCF3380CAE48d630DA13462E3950',
bsc: '0x08B277154218CCF3380CAE48d630DA13462E3950'
},
exclude: {
ethereum: ['0x6B175474E89094C44Da98b954EedeAC495271d0F'],
bsc: ['0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82']
}
})
//[
// {
// "name": "DePay",
// "symbol": "DEPAY",
// "address": "0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb",
// "blockchain": "ethereum",
// "type": "20",
// "balance": "212816860003097638129"
// }
//]
Drips every single asset immediately after resolved and all assets after all assets have been resolved (just as getAssets):
import { dripAssets } from '@depay/web3-assets'
let allAssets = await dripAssets({
accounts: { ethereum: '0x08B277154218CCF3380CAE48d630DA13462E3950', bsc: '0x08B277154218CCF3380CAE48d630DA13462E3950' },
priority: [
{ blockchain: 'ethereum', address: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb' },
{ blockchain: 'bsc', address: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb' },
{ blockchain: 'ethereum', address: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2' },
{ blockchain: 'bsc', address: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c' },
],
drip: (asset)=>{
// {
// "name": "DePay",
// "symbol": "DEPAY",
// "address": "0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb",
// "blockchain": "ethereum",
// "type": "20",
// "balance": "212816860003097638129"
// }
}
})
Only drips assets and balances for given token addresses.
import { dripAssets } from '@depay/web3-assets'
let assets = await dripAssets({
accounts: {
ethereum: '0x08B277154218CCF3380CAE48d630DA13462E3950',
bsc: '0x08B277154218CCF3380CAE48d630DA13462E3950'
},
only: {
ethereum: ['0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb'],
bsc: ['0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb']
},
drip: (asset)=>{
// {
// "name": "DePay",
// "symbol": "DEPAY",
// "address": "0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb",
// "blockchain": "ethereum",
// "type": "20",
// "balance": "212816860003097638129"
// }
}
})
Drips all assets except the ones you "exclude":
import { dripAssets } from '@depay/web3-assets'
let assets = await dripAssets({
accounts: {
ethereum: '0x08B277154218CCF3380CAE48d630DA13462E3950',
bsc: '0x08B277154218CCF3380CAE48d630DA13462E3950'
},
exclude: {
ethereum: ['0x6B175474E89094C44Da98b954EedeAC495271d0F'],
bsc: ['0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82']
},
drip: (asset)=>{
// {
// "name": "DePay",
// "symbol": "DEPAY",
// "address": "0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb",
// "blockchain": "ethereum",
// "type": "20",
// "balance": "212816860003097638129"
// }
}
})
yarn install
yarn dev
npm publish
FAQs
JavaScript library to retrieve Web3 assets of a given or connected wallet/account.
The npm package @depay/web3-assets receives a total of 317 weekly downloads. As such, @depay/web3-assets popularity was classified as not popular.
We found that @depay/web3-assets demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
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.
Security News
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.