Developer Guide
Integrate Zync Wallet into your dApp
TypeScript Definitions
Download for full IntelliSense support:
Download zyncwallet.d.tsPlace in: src/types/zyncwallet.d.ts
Installation
No npm package needed! Zync Wallet injects window.zyncwallet automatically.
Quick Start
// Check if installed
if (window.zyncwallet) {
const result = await window.zyncwallet.connect();
console.log('Connected:', result.address);
} else {
console.log('Install Zync Wallet');
}
Core Methods
connect()
const result = await window.zyncwallet.connect();
// { address: "t1...", network: "mainnet", connected: true }
getBalance()
const result = await window.zyncwallet.getBalance();
// { balance: 1685775, balanceZec: "0.01685775" }
sendZec()
await window.zyncwallet.sendZec({
to: 't1...',
amount: 0.001
});
Zinc Protocol (ZRC-20)
Deploy Token
await window.zyncwallet.deployZrc20({
tick: 'TEST',
max: 21000000,
limit: 1000,
decimals: 8
});
Mint & Transfer
await window.zyncwallet.mintZrc20({
deployTxid: 'abc...',
amount: 100
});
await window.zyncwallet.transferZrc20({
deployTxid: 'abc...',
amount: 50,
to: 't1...'
});
Zerdinals Protocol
Inscribe Data
await window.zyncwallet.inscribe({
content: 'Hello Zcash!',
mimeType: 'text/plain'
});
Mint NFT
await window.zyncwallet.mintNft({
collectionTxid: 'abc...',
content: '',
mimeType: 'image/svg+xml'
});
Event Listeners
window.zyncwallet.on('accountsChanged', ({ address }) => {
console.log('Switched:', address);
});
window.zyncwallet.on('networkChanged', ({ network }) => {
console.log('Network:', network);
});
window.zyncwallet.on('disconnect', () => {
console.log('Disconnected');
});
Error Handling
try {
await window.zyncwallet.connect();
} catch (error) {
console.error(error.message);
}
Best Practices
- Always check
window.zyncwalletexists - Handle user rejections gracefully
- Listen to events for state changes
- Check network (mainnet vs testnet)
- Test on testnet first
Developer FAQ
Click any question to see the answer
How do I detect if Zync Wallet is installed?
Check if window.zyncwallet exists. You can listen for the zyncwallet#initialized event or poll for the object after page load.
Can I integrate both Zinc and Zerdinals in one dApp?
Yes! Zync Wallet's API supports both protocols. Use the appropriate methods for each protocol - ZRC-20 operations for Zinc and inscription methods for Zerdinals.
How do I handle network switching?
Listen to the networkChanged event. Always verify the current network matches your dApp's requirements before executing transactions.
What happens if the user rejects my request?
All wallet methods return promises that will reject with an error if the user denies the request. Always wrap calls in try/catch blocks and handle rejections gracefully.
Can I request specific permissions?
Use window.zyncwallet.request({ method: 'wallet_requestPermissions' }) to request specific permissions from the user.
How do I test my integration?
Use testnet for development. You can request testnet ZEC from faucets and test all inscription and token operations without real funds.
Is there TypeScript support?
Yes! Download zyncwallet.d.ts from the link above for full TypeScript definitions and IntelliSense support in your IDE.
How do I get inscription data for a specific address?
Use the Zync indexer API endpoint to query inscriptions by address. The wallet provides helper methods for fetching ZRC-20 balances and NFT ownership.
Can users sign arbitrary messages?
Yes, use window.zyncwallet.signMessage(message) to request the user to sign a message with their private key.
What about transaction fees?
Transaction fees are automatically calculated based on network conditions. Users see the total cost (amount + fees) before confirming any transaction.
