Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
@blockchain-web3/web3-tg-sdk
Advanced tools
npm install @uxuycom/web3-tg-sdk
import { WalletTgSdk } from 'https://cdn.jsdelivr.net/npm/@uxuycom/web3-tg-sdk';
import { WalletTgSdk } from '@uxuycom/web3-tg-sdk'
const { ethereum } = new WalletTgSdk({
metaData: {
name: 'your name',
icon:"https://example.com/icon.png"
}
})
The supported methods are consistent with the main methods of the official website
support version >=0.1.0
import TronLinkProvider from '@uxuycom/web3-tg-sdk/dist/tronLinkProvider.es'
const tronLink = new TronLinkProvider({
injected: true, // Whether TronLink is injected into the window. `window.tronLink`
metaData: {
name: 'your name',
icon:"https://example.com/icon.png"
}
});
Based on your request, I'll rephrase the content in the image using more professional open-source project terminology:
MetaMask Standard Wallet Integration (Beta)
We are pleased to announce the integration of MetaMask's standard wallet. Connection can now be established with a single line of code.
Current Status:
Code snippet for connection:
import { WalletTgSdk } from '@uxuycom/web3-tg-sdk'
const { ethereum } = new WalletTgSdk({
injected: true // Whether ethereum is injected into the window; if MetaMask is present, it will not be injected.
})
//Trigger Telegram
ethereum
// use window.ethereum to interact with the wallet
window.ethereum
Ethereum Provider API
Supported Networks: [Additional details would be listed here]
Note: This beta release focuses on core functionality. We appreciate community feedback as we work towards expanding capabilities and refining the integration.
The UXUY Wallet Connection is designed to be multi-chain. The following chains are supported:
Chain | ChainID |
---|---|
Ethereum | 1 (0x1) |
BNB Chain | 56 (0x38) |
Base | 8453 (0x2105) |
Arbitrum | 42161 (0xa4b1) |
Polygon | 137 (0x89) |
Fantom | 250 (0xfa) |
Optimism | 10 (0xa) |
Avalanche C-Chain | 43114 (0xa86a) |
zkSync Era | 324 (0x144) |
Linea | 59144 (0xe708) |
Core | 1116 (0x45c) |
zkLink | 810180 (0xc5cc4) |
The request
method is used to make RPC requests to the connected wallet. It takes an object with the following properties:
id
(optional): A number or string that identifies the request.method
: The RPC method to request.params
(optional): An array or object of parameters for the RPC method.The method returns a Promise that resolves with the result of the RPC method call.
interface RequestArguments {
id?:number | string
/** The RPC method to request. */
method: string;
/** The params of the RPC method, . */
params?: Array<unknown> | object;
}
ethereum.request = (args: RequestArguments): Promise<any>
connect to the wallet and return the address of the connected wallet.
ethereum.request({ method: 'eth_requestAccounts' })
return the address of the connected wallet.
ethereum.request({ method: 'eth_accounts' })
return the chainId of the connected wallet.
ethereum.request({ method: 'eth_chainId' })
switch the connected wallet to the specified chainId.
try {
await ethereum.request({
method: 'wallet_switchEthereumChain',
params: [{ chainId: '0xf00' }],
});
} catch (switchError) {
// This error code indicates that the chain has not been added to Uxuy Wallet.
}
send a transaction to the connected wallet.
const accounts = await ethereum.request({ method: 'eth_accounts', params: [{}] })
const fromAddress = ethereum.selectedAddress
const transactionParameters = {
nonce: '0x00', // ignored by Uxuy Wallet
gasPrice: '0x09184e72a000', // customizable by user during Uxuy Wallet confirmation.
gas: '0x2710', // customizable by user during Uxuy Wallet confirmation.
to: '0x0000000000000000000000000000000000000000', // Required except during contract publications.
from: fromAddress || accounts[0], // must match user's active address.
value: '0x00', // Only required to send ether to the recipient from the initiating external account.
data:
'0x7f7465737432000000000000000000000000000000000000000000000000000000600057', // Optional, but used for defining smart contract creation and interaction.
chainId: '0x3', // Used to prevent transaction reuse across blockchains. Auto-filled by Uxuy Wallet.
};
ethereum.request(
{
method: 'eth_sendTransaction',
params: [
transactionParameters
]
}
)
You can refer to docs signing-data-with-metamask eth-sig-util
sign a message with the connected wallet.
ethereum.request({ method: 'personal_sign', params: ['hello', '0x1234567890'] })
ethereum.request({ method: 'eth_signTypedData_v3', params: [{}, '0x1234567890'] })
ethereum.request({ method: 'eth_signTypedData_v4', params: [{}] })
Notify when address and network change. Uses eventemitter3.
ethereum.on('accountsChanged', handler: (accounts: Array<string>) => void);
ethereum.on('accountChanged', (accounts) => {
console.log(accounts || [])
})
ethereum.on('chainChanged', (chainId) => {
console.log(chainId)
})
// remove all event listeners
ethereum.removeAllListeners();
function handleAccountsChainChanged() {
ethereum.on('accountsChanged', ([address]) => {
// Handle the new accounts, or lack thereof.
// "accounts" will always be an array, but it can be empty.
alert('address changed');
});
ethereum.on('chainChanged', async (chainId) => {
// Handle the new chain.
// Correctly handling chain changes can be complicated.
// We recommend reloading the page unless you have good reason not to.
alert('chainid changed');
});
}
// add event listener
function handleAccountsChanged(accounts) {
// ...
}
//remove
ethereum.removeListener('accountsChanged', handleAccountsChanged); // only remove one
ethereum.on('accountsChanged', handleAccountsChanged);
FAQs
web3 sdk for tg
We found that @blockchain-web3/web3-tg-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.