diff --git a/docs/2.build/1.chain-abstraction/chain-signatures/chain-signatures.md b/docs/2.build/1.chain-abstraction/chain-signatures/chain-signatures.md index b4bfdd16a7c..78a78b5088b 100644 --- a/docs/2.build/1.chain-abstraction/chain-signatures/chain-signatures.md +++ b/docs/2.build/1.chain-abstraction/chain-signatures/chain-signatures.md @@ -61,8 +61,7 @@ Chain Signatures use [`derivation paths`](../../../1.concepts/abstraction/chain- - The NEAR address (e.g., `example.near`, `example.testnet`, etc.) - A derivation path (a string such as `ethereum-1`, `ethereum-2`, etc.) -- The MPC service's public key - - `secp256k1:4NfTiv3UsGahebgTaHyD9vF8KYKMBnfd6kh94mK6xv8fGBiJB8TBtFMP5WWXz6B89Ac1fbpzPwAvoyQebemHFwx3` +- The MPC service's public key (see the tip bellow for the MPC service public keys) We provide code to derive the address, as it's a complex process that involves multiple steps of hashing and encoding: @@ -81,21 +80,22 @@ We provide code to derive the address, as it's a complex process that involves m -:::info +:::tip -The same NEAR account and path will always produce the same address on the target blockchain. +We recommend hardcoding the derivation paths in your application to ensure the signature request is made to the correct account -- `example.near` + `ethereum-1` = `0x1b48b83a308ea4beb845db088180dc3389f8aa3b` -- `example.near` + `ethereum-2` = `0x99c5d3025dc736541f2d97c3ef3c90de4d221315` +- **v1.signer-prod.testnet** (testnet): `secp256k1:4NfTiv3UsGahebgTaHyD9vF8KYKMBnfd6kh94mK6xv8fGBiJB8TBtFMP5WWXz6B89Ac1fbpzPwAvoyQebemHFwx3` + +- **v1.signer** (mainnet): `secp256k1:3tFRbMqmoa6AAALMrEFAYCEoHcqKxeW38YptwowBVBtXK1vo36HDbUWuR6EZmoK4JcH6HDkNMGGqP1ouV7VZUWya` ::: -:::tip +:::info -We recommend hardcoding the derivation paths in your application to ensure the signature request is made to the correct account +The same NEAR account and path will always produce the same address on the target blockchain. -#### v1.signer-prod.testnet -`secp256k1:4NfTiv3UsGahebgTaHyD9vF8KYKMBnfd6kh94mK6xv8fGBiJB8TBtFMP5WWXz6B89Ac1fbpzPwAvoyQebemHFwx3` +- `example.near` + `ethereum-1` = `0x1b48b83a308ea4beb845db088180dc3389f8aa3b` +- `example.near` + `ethereum-2` = `0x99c5d3025dc736541f2d97c3ef3c90de4d221315` ::: diff --git a/docs/2.build/1.chain-abstraction/chain-signatures/getting-started.md b/docs/2.build/1.chain-abstraction/chain-signatures/getting-started.md index b94bdfdf7b2..ace96e3b6e1 100644 --- a/docs/2.build/1.chain-abstraction/chain-signatures/getting-started.md +++ b/docs/2.build/1.chain-abstraction/chain-signatures/getting-started.md @@ -1,37 +1,63 @@ --- id: getting-started title: Getting Started with Chain Signatures -hide_table_of_contents: true --- -Chain Signatures is a groundbreaking technology built on NEAR that enables NEAR accounts, including smart contracts, to sign and execute transactions across multiple blockchains. This innovation leverages Multi-Party Computation (MPC) and a distributed network of node operators to create joint signatures from arbitrary payloads, allowing NEAR users to control external blockchain accounts. +Chain Signatures is a groundbreaking technology built on NEAR that enables all accounts, including smart contracts, to sign and execute transactions across multiple blockchains. ![img](https://pages.near.org/wp-content/uploads/2024/02/acct-abstraction-blog-1.png) -This technology enhances blockchain interoperability, giving ownership of diverse assets, cross-chain accounts, and data to a single NEAR account. +This innovation leverages Multi-Party Computation (MPC) and a distributed network of node operators to create joint signatures from arbitrary payloads, allowing NEAR users to control external blockchain accounts. + +Chain Signatures enhances blockchain interoperability, giving ownership of diverse assets, cross-chain accounts, and data to a single NEAR account. --- -## How Does It Work? +## How does it work? + +When a NEAR account - could be a user or a **smart contract** - wants to interact with a foreign blockchain, it just need to follow four simple steps. + +#### 1. Deriving Foreign Addresses + +Chain Signatures uses [derivation paths](../../../1.concepts/abstraction/chain-signatures.md#derivation-paths-one-account-multiple-chains) to represent accounts on foreign blockchains + +The NEAR account’s name and the derivation path are used to mathematically derive a unique address for the user on the foreign blockchain + +
+ + Derivation Paths + +A NEAR account will always derive the same address on the foreign blockchain using the same derivation path + +Notice that, since the foreign address is derived from the NEAR account name, it is not possible for another NEAR account to control the same address -Chain Signatures operates through a series of steps to enable seamless cross-chain transactions: +
-1. **Deriving Foreign Addresses:** - * Chain Signatures uses derivation paths to represent accounts on foreign blockchains. - * The NEAR account’s name and the derivation path are used to mathematically [derive a unique address](https://docs.near.org/concepts/abstraction/chain-signatures\#derivation-paths-one-account-multiple-chains) for the user on the foreign blockchain. -2. **Creating the Transaction:** - * The client constructs the hash of the transaction to be signed, which varies by the target blockchain. -3. **Requesting the Signature:** - * A NEAR account or smart contract calls the sign method of the MPC smart contract ([v1.signer](https://nearblocks.io/address/v1.signer)) to sign a payload. -4. **Relaying the Signature:** - * The client reconstructs the valid transaction using the signature and broadcasts it to the destination blockchain. -This process eliminates the need for traditional bridges and enables developers to build innovative cross-chain DeFi applications with seamless user experiences. +#### 2. Creating the Transaction + +The client constructs the foreign transaction to be signed, which varies depending on the target blockchain + +#### 3. Requesting the Signature + +A NEAR account or contract calls the sign method of the MPC smart contract ([v1.signer](https://nearblocks.io/address/v1.signer)) to sign the transaction and waits while our MPC service generates the signature + +#### 4. Relaying the Signature + +Once the signature is ready, the client reconstructs the signed transaction using the signature and broadcasts it to the destination blockchain + +:::tip + +Using Chain Signatures, developers can build cross-chain DeFi applications with seamless user experiences, eliminating the need for traditional bridges. This process eliminates the need for traditional bridges and enables developers to build innovative cross-chain DeFi applications with seamless user experiences. + +::: --- ## Use Cases +Chain Signatures can be used to build a wide range of applications that leverage blockchain interoperability. Here are some examples: + 1. **DeFi on Bitcoin (and other chain without smart contracts)** * Chain signatures allow NEAR smart contract to program assets on Bitcoin * Build lending, swaps, runes launchpads, passkey-based Bitcoin wallets, and more @@ -69,7 +95,5 @@ This process eliminates the need for traditional bridges and enables developers To dive deeper into Chain Signatures and its applications, you can explore the following resources: -* **Technical Blogs and Deep Dives:** - * Read [high-level use cases](https://pages.near.org/blog/unlocking-multichain-web3-with-near-chain-signatures) and technical [explainer](https://near.org/blog/unlocking-web3-usability-with-account-aggregation) posts on the NEAR blog. -* **Community and Support:** - * Engage with the NEAR community on social media platforms like Twitter and participate in discussions to stay updated on the latest developments. \ No newline at end of file +- **Technical Blogs and Deep Dives:** Read [high-level use cases](https://pages.near.org/blog/unlocking-multichain-web3-with-near-chain-signatures) and technical [explainer](https://near.org/blog/unlocking-web3-usability-with-account-aggregation) posts on the NEAR blog +* **Community and Support:** Engage with the NEAR community on social media platforms like Twitter and participate in discussions to stay updated on the latest developments diff --git a/docs/2.build/1.chain-abstraction/multichain-gas-relayer/getting-started.md b/docs/2.build/1.chain-abstraction/multichain-gas-relayer/getting-started.md index 459baa1f1bd..fb7feca4e55 100644 --- a/docs/2.build/1.chain-abstraction/multichain-gas-relayer/getting-started.md +++ b/docs/2.build/1.chain-abstraction/multichain-gas-relayer/getting-started.md @@ -1,60 +1,71 @@ --- id: getting-started title: "Multichain Gas Relayer: Getting Started Guide" -hide_table_of_contents: true --- -The Multichain Gas Relayer provides gas abstraction for foreign chains outside of NEAR. This system, in conjunction with NEAR Chain Signatures, allows NEAR users to transact on other blockchains and pay for gas using NEAR, USDC, USDT, or other NEAR-based tokens from a single NEAR account. +[Chain Signatures](../chain-signatures/getting-started.md) lets users manage remote accounts and transact on any blockchain from a single NEAR account. The Multichain Gas Relayer further simplifies this process by eliminating the need for users to acquire the tokens needed in the foreign chain to execute their transactions. ![img](https://pages.near.org/wp-content/uploads/2024/02/acct-abstraction-blog-1.png) -Chain Signatures lets users manage remote accounts and transact on any blockchain from a single NEAR account. The Multichain Gas Relayer further simplifies this process by eliminating the need for users to acquire native gas tokens to transact on other chains. +In other words, the Multichain Gas Relayer provides gas abstraction for foreign chains, allowing NEAR accounts to pay for the gas needed in the target chain using our native token (NEAR) and fungible tokens (e.g. USDC and USDT). --- -## Why did NEAR create the Multichain Gas Relayer? +## Why a Multichain Gas Relayer? -NEAR's mission is to build blockchain infrastructure for Chain Abstracted applications. Chain abstraction aims to make blockchain technology more user-friendly by simplifying interactions. A key step in achieving this is reducing the complexity of paying for transaction gas across different blockchains. Users should be able to pay for cross-chain transactions with a single asset or have the gas fees fully sponsored on their behalf. +NEAR's mission is to build blockchain infrastructure for Chain Abstracted applications. Chain abstraction aims to make blockchain technology more user-friendly by simplifying interactions. + +A key step in achieving this is reducing the complexity of paying for transaction gas across different blockchains. Users should be able to pay for cross-chain transactions with a single asset or have the gas fees fully sponsored on their behalf. --- -## How does it work? +## How Does it Work? The Multichain Gas Relayer has 3 core components: -1. **Gas Station Smart Contract**: A smart contract on NEAR that manages the creation, signing, of transactions to foreign chains. It also handles gas fee calculations and collects NEAR tokens for gas payments on foreign chains. -2. **Multichain Relayer Server**: This server coordinates the relaying of transactions between NEAR and other blockchains. It listens for signed transaction payloads and submits them to the appropriate foreign chain RPCs. -3. **Chain Signatures**: A network of distributed Multi-Party Computation (MPC) signers that cooperatively sign transactions. This ensures secure transaction signing and validation on the NEAR blockchain before relaying to foreign chains. +1. **Gas Station Smart Contract**: A smart contract on NEAR that manages the creation, signing, of transactions to foreign chains. It also handles gas fee calculations and collects NEAR tokens for gas payments on foreign chains + +2. **Multichain Relayer Server**: This server coordinates the relaying of transactions between NEAR and other blockchains. It listens for signed transaction payloads and submits them to the appropriate foreign chain RPCs + +3. **Chain Signatures**: A network of distributed Multi-Party Computation (MPC) signers that cooperatively sign transactions. This ensures secure transaction signing and validation on the NEAR blockchain before relaying to foreign chains + +#### System Workflow -### System Workflow +![chain-signatures](/docs/assets/welcome-pages/multi-chain-gas-diagram.png) +_Diagram of a chain signature in NEAR with gas being covered by the Relayer_ -1. **Transaction Creation**: Users initiate a transaction on NEAR, specifying the foreign chain transaction and attaching NEAR tokens to cover gas fees on the foreign chain. This transaction is sent to the Gas Station Contract. -2. **Transaction Signing**: The Gas Station Contract invokes Chain Signatures MPC signing service to sign the transaction. This step may require multiple calls due to gas limitations on NEAR, especially for complex transactions. -3. **Event Emission and Indexing**: Once the transactions are signed, the Gas Station Contract emits an event. The Gas Station Event Indexer picks up this event and triggers the Multichain Relayer Server to relay the signed transactions. -4. **Relaying Transactions**: The Multichain Relayer Server first sends a funding transaction to ensure the user’s account on the foreign chain has sufficient gas. Once confirmed, it sends the user’s originally intended signed transaction to the foreign chain for execution. +1. **Transaction Creation**: An account sends a transaction to the Gas Station Contract, specifying the foreign chain transaction and attaching NEAR tokens to cover gas fees on the foreign chain. + +2. **Transaction Signing**: The Gas Station Contract invokes Chain Signatures MPC signing service to sign the transaction. This step may require multiple calls due to gas limitations on NEAR, especially for complex transactions + +3. **Event Emission and Indexing**: Once the transactions are signed, the Gas Station Contract emits an event. The Gas Station Event Indexer picks up this event and triggers the Multichain Relayer Server to relay the signed transactions + +4. **Relaying Transactions**: The Multichain Relayer Server first sends a funding transaction to ensure the user’s account on the foreign chain has sufficient gas. Once confirmed, it sends the user’s originally intended signed transaction to the foreign chain for execution --- ## Example Real-World Flow -* Alice has an alice.near account that maps to a remote Optimism (OP) address, 0xabc +* Alice has an `alice.near` account that maps to a remote Optimism (OP) address, `0xabc` * Alice wants to interact with a Farcaster application on OP using her NEAR account, but she prefers to pay for gas with assets she has on hand, specifically USDT * Alice initiates an on-chain action on Farcaster from her NEAR account. She sends the transaction to a gas station smart contract, including the OP transaction payload in the arguments and attaching the necessary USDT amount for the cross-chain gas payment -* The transaction bundle is sent to the NEAR gas station contract, which then forwards it to the NEAR MPC signing service. This bundle includes (1) the transaction to fund the user's 0xabc address with the ETH needed for gas, and (2) the user's original transaction to take action on the Farcaster application +* The transaction bundle is sent to the NEAR gas station contract, which then forwards it to the NEAR MPC signing service. This bundle includes (1) the transaction to fund the user's `0xabc` address with the ETH needed for gas, and (2) the user's original transaction to take action on the Farcaster application * The MPC service will sign both transactions and forward the signed transactions back to the gas station contract -* The relayer operator will observe the events (signed transactions) emitted from the gas station contract and submit them to the Optimism network. This process starts by initiating a fund transfer from a treasury paymaster account on Optimism that holds ETH. The paymaster account will transfer ETH to the user's 0xabc address, equivalent to the USDT originally sent by the user -* Then the relayer will submit the final transaction, and the originally intended Farcaster transaction will be executed from the user's 0xabc address, using ETH to cover the gas +* The relayer operator will observe the events (signed transactions) emitted from the gas station contract and submit them to the Optimism network. This process starts by initiating a fund transfer from a treasury paymaster account on Optimism that holds ETH. The paymaster account will transfer ETH to the user's `0xabc` address, equivalent to the USDT originally sent by the user +* Then the relayer will submit the final transaction, and the originally intended Farcaster transaction will be executed from the user's `0xabc` address, using ETH to cover the gas --- ## What chains are supported? -The NEAR Multichain Gas Relayer supports cross-chain gas abstraction on Base, Optimism, Arbitrum and Binance Smart Chain, and Ethereum. These chains were selected based on multiple factors including interest from key partners, low gas fees, and fast finality for transactions. Support for EDDSA chains like Solana will be coming soon in conjunction with EDDSA support for NEAR chain signatures. +Currently, the Multichain Gas Relayer supports [Base](https://www.base.org/), [Optimism](https://www.optimism.io/), [Arbitrum](https://arbitrum.io/) and [Binance Smart Chain](https://www.bnbchain.org/en/bnb-smart-chain), and [Ethereum](https://ethereum.org/en/). + +These chains were selected based on multiple factors including interest from key partners, low gas fees, and fast finality for transactions. Support for EDDSA chains like [Solana](https://solana.com/) will be coming soon in conjunction with EDDSA support for NEAR chain signatures. --- ## Where can I go to learn more? -* Visit our [docs](https://docs.near.org/build/chain-abstraction/multichain-gas-relayer/overview) to learn more about how to integrate the Multichain Gas Relayer into your product +* Visit our [docs](./overview.md) to learn more about how to integrate the Multichain Gas Relayer into your product * Join the NEAR Chain Abstraction [developer group](https://t.me/chain\_abstraction) on Telegram to ask questions and discuss ideas with other developers. \ No newline at end of file diff --git a/docs/2.build/1.chain-abstraction/multichain-gas-relayer/overview.md b/docs/2.build/1.chain-abstraction/multichain-gas-relayer/overview.md index 199324ba8a6..e5187dfbec7 100644 --- a/docs/2.build/1.chain-abstraction/multichain-gas-relayer/overview.md +++ b/docs/2.build/1.chain-abstraction/multichain-gas-relayer/overview.md @@ -28,7 +28,7 @@ This section provides an overview of the system design, including the main compo 2. [**Gas Station Contract**](gas-station.md): A smart contract on NEAR that manages the creation, signing, and relaying of transactions to foreign chains. It also handles gas fee calculations and collects NEAR tokens for gas payments on foreign chains. -3. [**MPC Signing Service**](../chain-signatures.md): A network of trusted Multi-Party Computation (MPC) signers that cooperatively sign transactions. This ensures secure transaction signing and validation on the NEAR blockchain before relaying to foreign chains. +3. [**MPC Signing Service**](../chain-signatures/chain-signatures.md): A network of trusted Multi-Party Computation (MPC) signers that cooperatively sign transactions. This ensures secure transaction signing and validation on the NEAR blockchain before relaying to foreign chains. ### Technical Diagram diff --git a/website/static/docs/assets/welcome-pages/multi-chain-gas-diagram.png b/website/static/docs/assets/welcome-pages/multi-chain-gas-diagram.png new file mode 100644 index 00000000000..0be6e21339e Binary files /dev/null and b/website/static/docs/assets/welcome-pages/multi-chain-gas-diagram.png differ