From 1a9e4efccfc8b526e82ad18bae20d76884dda726 Mon Sep 17 00:00:00 2001 From: tyler-nguyen-4 Date: Mon, 30 Jun 2025 17:46:06 +0700 Subject: [PATCH 1/3] feat: update developer document with cardano integration & social links --- .vitepress/config.ts | 40 ++++--- CONTRIBUTING.md | 2 +- developers/extension-cardano.md | 179 ++++++++++++++++++++++++++++++++ developers/extension-wallet.md | 2 + 4 files changed, 206 insertions(+), 17 deletions(-) create mode 100644 developers/extension-cardano.md diff --git a/.vitepress/config.ts b/.vitepress/config.ts index 6c0b0bade..be720bd1f 100644 --- a/.vitepress/config.ts +++ b/.vitepress/config.ts @@ -338,6 +338,10 @@ export default { text: 'Bitcoin Cash', link: '/developers/extension-bitcoin-cash', }, + { + text: 'Cardano', + link: '/developers/extension-cardano', + }, { text: 'Cosmos', link: '/developers/extension-cosmos', @@ -390,32 +394,36 @@ export default { link: '/developers/mobile-bitcoin', }, { - text: 'Dogecoin', - link: '/developers/mobile-dogecoin', + text: 'Bitcoin Cash', + link: '/developers/mobile-bitcoin-cash', }, { - text: 'Litecoin', - link: '/developers/mobile-litecoin', + text: 'Cardano', + link: '/developers/mobile-cardano', }, { - text: 'Solana', - link: '/developers/mobile-solana', + text: 'Cosmos', + link: '/developers/mobile-cosmos', + }, + { + text: 'Dogecoin', + link: '/developers/mobile-dogecoin', }, { text: "Ethereum (EVM's)", link: '/developers/mobile-ethereum', }, { - text: 'Cosmos', - link: '/developers/mobile-cosmos', + text: 'Litecoin', + link: '/developers/mobile-litecoin', }, { - text: 'Tron', - link: '/developers/mobile-tron', + text: 'Solana', + link: '/developers/mobile-solana', }, { - text: 'Cardano', - link: '/developers/mobile-cardano', + text: 'Tron', + link: '/developers/mobile-tron', }, ], }, @@ -714,7 +722,7 @@ export default { text: '🔖 Community', collapsed: true, items: [ - { text: '🔹 X', link: 'https://x.com/xdefi_wallet' }, + { text: '🔹 X', link: 'https://x.com/ctrl_wallet' }, { text: '🔹 Discord', link: 'https://discord.gg/xdefi' }, { text: '🔹 Telegram', link: 'https://t.me/xdefi_announcements' }, { text: '🔹 GitHub', link: 'https://github.com/XDeFi-tech' }, @@ -734,9 +742,9 @@ export default { socialLinks: [ { icon: 'github', link: 'https://github.com/XDeFi-tech' }, - { icon: 'x', link: 'https://x.com/xdefi_wallet' }, - { icon: 'discord', link: 'https://discord.com/invite/xdefi' }, - { icon: { svg: telegramSVG }, link: 'https://t.me/xdefi_announcements' }, + { icon: 'x', link: 'https://x.com/ctrl_wallet' }, + { icon: 'discord', link: 'https://discord.gg/ctrlwallet' }, + { icon: { svg: telegramSVG }, link: 'https://t.me/ctrl_wallet' }, ], editLink: { diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 04c8bde29..155f1bcfe 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -62,7 +62,7 @@ When suggesting a feature, please provide as much detail as possible. Explain wh Discussions about the documentation take place on the [Ctrl Discord](https://discord.gg/xdefi). -We also available on [X](https://x.com/xdefi_wallet) and [Telegram](https://t.me/xdefi_announcements). +We also available on [X](https://x.com/ctrl_wallet) and [Telegram](https://t.me/xdefi_announcements). ## Code of Conduct diff --git a/developers/extension-cardano.md b/developers/extension-cardano.md new file mode 100644 index 000000000..8a0a7934b --- /dev/null +++ b/developers/extension-cardano.md @@ -0,0 +1,179 @@ +# Extension Wallet Cardano Integration + +Develop Cardano based dApps + +It injects a CIP-30 compatible provider in `window.cardano.ctrl` and follows the [CIP-30 specification](https://cips.cardano.org/cip/CIP-30) for dApp-wallet communication. + +### Introduction + +- [CIP-30 specification](https://cips.cardano.org/cip/CIP-30) +- [Cardano dApp-Wallet Web Bridge documentation](https://cips.cardano.org/cip/CIP-30) + +### Example dApp + +- [Cardano Web3 example](https://github.com/XDeFi-tech/examples-dapps-sdk/tree/main/cardano) + +### How to detect XDEFI's Cardano provider + +As the official [CIP-30 guide](https://cips.cardano.org/cip/CIP-30) mentioned: + +```javascript +window.onload = async () => { + if (!window.cardano?.ctrl) { + alert("Please install XDEFI extension"); + } else { + const cardanoWallet = window.cardano.ctrl; + + // Enabling before using the Cardano wallet is recommended. + // This method will ask the user whether to allow access if they haven't visited this website. + // Also, it will request that the user unlock the wallet if the wallet is locked. + const api = await cardanoWallet.enable(); + + // You can get the balance using getBalance method + const balance = await api.getBalance(); + + // Get all used addresses + const usedAddresses = await api.getUsedAddresses(); + + console.log('Wallet connected successfully'); + } +}; +``` + +### Integrate Cardano dApps with Ctrl (fka XDEFI) + +#### `window.cardano.ctrl` + +Ctrl (fka XDEFI) injects `window.cardano.ctrl` as a [CIP-30](https://cips.cardano.org/cip/CIP-30) compatible provider; + +As a dApp developer, you can check if `window.cardano && window.cardano.ctrl` is defined. + +If it is, XDEFI is injected and supports Cardano. + +You can use it with regular Cardano libraries such as cardano-serialization-lib. + +**Basic Connection Example** + +```javascript +// Check if Ctrl (fka XDEFI) is available +if (window.cardano && window.cardano.ctrl) { + const cardanoWallet = window.cardano.ctrl; + + // Enable the wallet (request connection) + try { + const api = await cardanoWallet.enable(); + console.log('Connected to Ctrl wallet'); + + // Now you can use the API methods + const balance = await api.getBalance(); + const addresses = await api.getUsedAddresses(); + + } catch (error) { + console.error('Failed to connect:', error); + } +} else { + console.log('Ctrl (fka XDEFI) is not installed'); +} +``` + +### Basic API + +Please find the Full Basic API on [CIP-30 specification](https://cips.cardano.org/cip/CIP-30) + +#### Connect using `enable` + +```javascript +enable(): Promise +``` + +The `window.cardano.ctrl.enable()` method requests the extension to be unlocked if it's currently locked. If the user hasn't given permission to the webpage, it will ask the user to give permission for the webpage to access XDEFI. This method follows the [CIP-30 enable specification](https://cips.cardano.org/cip/CIP-30). + +#### Get Network ID + +```javascript +getNetworkId(): Promise +``` + +Returns the network ID of the currently connected network. Returns `0` for testnet and `1` for mainnet. See [CIP-30 getNetworkId](https://cips.cardano.org/cip/CIP-30). + +#### Get Balance + +```javascript +getBalance(): Promise> +``` + +Returns the total balance available of the wallet as CBOR-encoded value. This is the same as summing the results of `getUtxos()`, but maintained by the wallet in a more efficient manner. See [CIP-30 getBalance](https://cips.cardano.org/cip/CIP-30). + +#### Get UTXOs + +```javascript +getUtxos(amount?: cbor, paginate?: Paginate): Promise[] | null> +``` + +Returns a list of all UTXOs (unspent transaction outputs) controlled by the wallet. If `amount` is provided, filters UTXOs by minimum value. See [CIP-30 getUtxos](https://cips.cardano.org/cip/CIP-30). + +#### Get Collateral + +```javascript +getCollateral(amount?: cbor): Promise[] | null> +``` + +Returns UTXOs suitable for use as collateral inputs for transactions with Plutus script witnesses. The maximum amount is typically 5 ADA. See [CIP-30 getCollateral](https://cips.cardano.org/cip/CIP-30). + +#### Get Used Addresses + +```javascript +getUsedAddresses(paginate?: Paginate): Promise[]> +``` + +Returns a list of all used addresses controlled by the wallet. These are addresses that have been included in some on-chain transaction. See [CIP-30 getUsedAddresses](https://cips.cardano.org/cip/CIP-30). + +#### Get Unused Addresses + +```javascript +getUnusedAddresses(): Promise[]> +``` + +Returns a list of unused addresses controlled by the wallet. See [CIP-30 getUnusedAddresses](https://cips.cardano.org/cip/CIP-30). + +#### Get Change Address + +```javascript +getChangeAddress(): Promise> +``` + +Returns an address owned by the wallet that should be used as a change address to return leftover assets during transaction creation. See [CIP-30 getChangeAddress](https://cips.cardano.org/cip/CIP-30). + +#### Get Reward Addresses + +```javascript +getRewardAddresses(): Promise[]> +``` + +Returns the reward addresses owned by the wallet. This can return multiple addresses for multi-stake-keys wallets. See [CIP-30 getRewardAddresses](https://cips.cardano.org/cip/CIP-30). + +#### Sign Transaction + +```javascript +signTx(tx: cbor, partialSign?: bool): Promise> +``` + +Requests that a user sign the unsigned portions of the supplied transaction. If `partialSign` is true, the wallet only tries to sign what it can. See [CIP-30 signTx](https://cips.cardano.org/cip/CIP-30). + +#### Sign Data + +```javascript +signData(addr: Address, payload: Bytes): Promise +``` + +This endpoint utilizes the CIP-0008 signing spec for standardization/safety reasons. It allows the dApp to request the user to sign a payload conforming to said spec. See [CIP-30 signData](https://cips.cardano.org/cip/CIP-30). + +#### Submit Transaction + +```javascript +submitTx(tx: cbor): Promise +``` + +Requests that a transaction be sent through the wallet. Returns the transaction ID for the dApp to track. See [CIP-30 submitTx](https://cips.cardano.org/cip/CIP-30). + +For more details, refer to the [CIP-30 Cardano dApp-Wallet Web Bridge](https://cips.cardano.org/cip/CIP-30) specification. diff --git a/developers/extension-wallet.md b/developers/extension-wallet.md index 8405f2dd9..2e1d1c844 100644 --- a/developers/extension-wallet.md +++ b/developers/extension-wallet.md @@ -24,3 +24,5 @@ Ctrl Wallet injects into the window object to dapps multiple wallet providers to - window.xfi.tron: [Tron provider](./extension-tron) - window.ethereum : [Ethereum provider](./extension-evms) - window.keplr : [Keplr/Cosmos chains provider](./extension-cosmos) +- window.cardano + - window.cardano.ctrl: [Cardano provider](./extension-cardano) From d5f21f6020f2905b470dd2d577516ab377d0ad03 Mon Sep 17 00:00:00 2001 From: tyler-nguyen-4 Date: Mon, 30 Jun 2025 17:50:27 +0700 Subject: [PATCH 2/3] fix: update social links --- .vitepress/config.ts | 10 +++++----- CONTRIBUTING.md | 6 +++--- developers/introduction.md | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.vitepress/config.ts b/.vitepress/config.ts index be720bd1f..5253fd1b1 100644 --- a/.vitepress/config.ts +++ b/.vitepress/config.ts @@ -723,13 +723,13 @@ export default { collapsed: true, items: [ { text: '🔹 X', link: 'https://x.com/ctrl_wallet' }, - { text: '🔹 Discord', link: 'https://discord.gg/xdefi' }, - { text: '🔹 Telegram', link: 'https://t.me/xdefi_announcements' }, + { text: '🔹 Discord', link: 'https://discord.gg/ctrlwallet' }, + { text: '🔹 Telegram', link: 'https://t.me/ctrl_wallet' }, { text: '🔹 GitHub', link: 'https://github.com/XDeFi-tech' }, - { text: '🔹 Blog', link: 'https://xdefi.io/blog' }, + { text: '🔹 Blog', link: 'https://ctrl.xyz/news' }, { - text: '🔹 $XDEFI on Coingecko', - link: 'https://www.coingecko.com/en/coins/xdefi', + text: '🔹 $CTRL on Coingecko', + link: 'https://www.coingecko.com/en/coins/ctrl-wallet', }, ], }, diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 155f1bcfe..fcf7afaa7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,7 +10,7 @@ Following these guidelines helps to communicate that you respect the time of the Ctrl (fka XDEFI) Technologies is a community-driven project, and we welcome contributions from the community. Whether you're fixing a typo, adding a new feature, or changing the documentation, we'd love to have your contributions. -Please, don't use the issue tracker for personal support requests. Instead, use the [Ctrl Discord](https://discord.gg/xdefi) for support. +Please, don't use the issue tracker for personal support requests. Instead, use the [Ctrl Discord](https://discord.gg/ctrlwallet) for support. ## Ground Rules @@ -60,9 +60,9 @@ When suggesting a feature, please provide as much detail as possible. Explain wh ## Community -Discussions about the documentation take place on the [Ctrl Discord](https://discord.gg/xdefi). +Discussions about the documentation take place on the [Ctrl Discord](https://discord.gg/ctrlwallet). -We also available on [X](https://x.com/ctrl_wallet) and [Telegram](https://t.me/xdefi_announcements). +We also available on [X](https://x.com/ctrl_wallet) and [Telegram](https://t.me/ctrl_wallet). ## Code of Conduct diff --git a/developers/introduction.md b/developers/introduction.md index 57733a24c..1c77f9cd7 100644 --- a/developers/introduction.md +++ b/developers/introduction.md @@ -12,7 +12,7 @@ Welcome developers! You are now ready to implement Ctrl (fka XDEFI) and level up You will found here direct access to all subtopics depending on your needs. -Don't hesitate to join our [Discord channel](https://discord.gg/xdefi) and ask any questions related to your developer experience with the community. +Don't hesitate to join our [Discord channel](https://discord.gg/ctrlwallet) and ask any questions related to your developer experience with the community. ## Ctrl Wallet integration From 3be5b185bf89cc61434154d71d4519238702415b Mon Sep 17 00:00:00 2001 From: tyler-nguyen-4 Date: Mon, 30 Jun 2025 18:04:34 +0700 Subject: [PATCH 3/3] fix: cip 30 response --- developers/extension-cardano.md | 11 +++++------ developers/extension-wallet.md | 1 + 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/developers/extension-cardano.md b/developers/extension-cardano.md index 8a0a7934b..724ff2f5b 100644 --- a/developers/extension-cardano.md +++ b/developers/extension-cardano.md @@ -6,8 +6,7 @@ It injects a CIP-30 compatible provider in `window.cardano.ctrl` and follows the ### Introduction -- [CIP-30 specification](https://cips.cardano.org/cip/CIP-30) -- [Cardano dApp-Wallet Web Bridge documentation](https://cips.cardano.org/cip/CIP-30) +- [CIP-30: Cardano dApp-Wallet Web Bridge documentation](https://cips.cardano.org/cip/CIP-30) ### Example dApp @@ -123,7 +122,7 @@ Returns UTXOs suitable for use as collateral inputs for transactions with Plutus #### Get Used Addresses ```javascript -getUsedAddresses(paginate?: Paginate): Promise[]> +getUsedAddresses(paginate?: Paginate): Promise ``` Returns a list of all used addresses controlled by the wallet. These are addresses that have been included in some on-chain transaction. See [CIP-30 getUsedAddresses](https://cips.cardano.org/cip/CIP-30). @@ -131,7 +130,7 @@ Returns a list of all used addresses controlled by the wallet. These are address #### Get Unused Addresses ```javascript -getUnusedAddresses(): Promise[]> +getUnusedAddresses(): Promise ``` Returns a list of unused addresses controlled by the wallet. See [CIP-30 getUnusedAddresses](https://cips.cardano.org/cip/CIP-30). @@ -139,7 +138,7 @@ Returns a list of unused addresses controlled by the wallet. See [CIP-30 getUnus #### Get Change Address ```javascript -getChangeAddress(): Promise> +getChangeAddress(): Promise
``` Returns an address owned by the wallet that should be used as a change address to return leftover assets during transaction creation. See [CIP-30 getChangeAddress](https://cips.cardano.org/cip/CIP-30). @@ -147,7 +146,7 @@ Returns an address owned by the wallet that should be used as a change address t #### Get Reward Addresses ```javascript -getRewardAddresses(): Promise[]> +getRewardAddresses(): Promise ``` Returns the reward addresses owned by the wallet. This can return multiple addresses for multi-stake-keys wallets. See [CIP-30 getRewardAddresses](https://cips.cardano.org/cip/CIP-30). diff --git a/developers/extension-wallet.md b/developers/extension-wallet.md index 2e1d1c844..eac686e2d 100644 --- a/developers/extension-wallet.md +++ b/developers/extension-wallet.md @@ -26,3 +26,4 @@ Ctrl Wallet injects into the window object to dapps multiple wallet providers to - window.keplr : [Keplr/Cosmos chains provider](./extension-cosmos) - window.cardano - window.cardano.ctrl: [Cardano provider](./extension-cardano) + - window.cardano.xdefi: [Cardano provider](./extension-cardano)