bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 10쪽 중 3쪽
r dApps deployed on the Sophon network, both on mainnet as well as on testnet.
## Key Features
### Virtual TestNets
Tenderly Virtual TestNets allow developers to create forked environments of the Sophon mainnet or testnet for safe and controlled testing. These environments can be configured to stay up-to-date with the latest mainnet transactions, ensuring that developers work with the most recent blockchain state.
**Benefits:**
* Real-time synchronisation with mainnet
* Safe testing without affecting on-chain data
* Improved contract iteration speed
<Check>
For more details, refer to the [Sophon Testnet RPC Reference](https://docs.tenderly.co/node/rpc-reference/sophon-testnet).
</Check>
### Node RPC
Tenderly provides high-performance RPC endpoints for both the Sophon mainnet and testnet, allowing developers to interact with the blockchain reliably and at scale.
**RPC Endpoints:**
* **Mainnet RPC Reference:** `https://sophon.gateway.tenderly.co/$TENDERLY_NODE_ACCESS_KEY`
* **Testnet RPC Reference:** `https://sophon-testnet.gateway.tenderly.co/$TENDERLY_NODE_ACCESS_KEY`
#### Example Configuration:
```javascript theme={null}
const provider = new ethers.providers.JsonRpcProvider('https://sophon.gateway.tenderly.co/$TENDERLY_NODE_ACCESS_KEY');
```
<Note>
Replace `$TENDERLY_NODE_ACCESS_KEY` with your actual access key obtained from the Tenderly dashboard. For this you need to sign up [here](https://dashboard.tenderly.co/register).
</Note>
### Smart Contract Debugging
Developers can leverage Tenderly’s real-time debugging tools to inspect transaction execution, variables, and state changes. This significantly improves the debugging process and helps identify contract issues before deployment.
**Debugging Features:**
* **Transaction Replays:** Re-execute failed transactions to diagnose issues.
* **Real-time Debugger:** Step through contract execution and inspect variables.
* **Gas Profiling:** Analyse gas consumption and optimize contract efficiency.
<Note>
For detailed usage, see the [debug\_traceCall reference](https://docs.tenderly.co/node/rpc-reference/sophon/debug_traceCall).
</Note>
### Simulation and Testing
Tenderly enables developers to simulate transactions before execution, reducing the risk of unexpected behaviour.
**Simulation Capabilities:**
* **Transaction Simulator:** Preview transaction outcomes before submission.
* **Forking Capabilities:** Create isolated forks of the Sophon mainnet for testing.
* **Unit Testing:** Execute smart contract tests in a controlled environment.
#### Example usage:
* **Mainnet Simulation:** [tenderly\_simulateTransaction](https://docs.tenderly.co/node/rpc-reference/sophon/tenderly_simulateTransaction)
* **Testnet Simulation:** [tenderly\_simulateTransaction](https://docs.tenderly.co/node/rpc-reference/sophon-testnet/tenderly_simulateTransaction)
### Gas Estimation
Tenderly provides advanced gas estimation to optimise transaction costs.
<Check>
For more details, check out the [tenderly\_estimateGas reference](https://docs.tenderly.co/node/rpc-reference/sophon/tenderly_estimateGas).
</Check>
### Monitoring and Alerting
Tenderly offers robust monitoring and alerting solutions, allowing developers to track the performance and security of their smart contracts.
**Monitoring Features:**
* **Real-time Alerts:** Notifications for failed transactions, gas spikes, and security threats.
* **Webhook Integrations:** Connect alerts with Slack, Discord, Telegram, or other tools.
* **Custom Metrics:** Monitor specific contract activities and dApp performance.
### Infrastructure Services
Tenderly provides essential infrastructure services to support developers in deploying and maintaining dApps on Sophon.
**Available Services:**
* **Tenderly Node:** High-performance RPC with built-in simulation and debugging tools.
* **Event Streaming:** Subscribe to real-time contract events.
* **Gas Estimation API:** Optimize gas fees for transactions.
## Getting Started
### 1. Set Up Your Tenderly Account
1. Sign up or log in to [Tenderly](https://dashboard.tenderly.co/)
2. Navigate to the **Sophon** integration page
3. Generate your **TENDERLY\_NODE\_ACCESS\_KEY**
### 2. Configure RPC in Your Project
```javascript theme={null}
const provider = new ethers.providers.JsonRpcProvider('https://sophon.gateway.tenderly.co/YOUR_ACCESS_KEY');
```
### 3. Fork the Sophon Mainnet/Testnet
```bash theme={null}
curl -X POST 'https://api.tenderly.co/api/v1/fork' \
-H 'Authorization: Bearer YOUR_ACCESS_KEY' \
-d '{"network_id":"sophon-mainnet"}'
```
### 4. Debug Transactions
```bash theme={null}
curl -X POST 'https://api.tenderly.co/api/v1/debug' \
-H 'Authorization: Bearer YOUR_ACCESS_KEY' \
-d '{"hash":"0xYourTransactionHash"}'
```
## Supported SDKs
Sophon is compatible with multiple programming languages and frameworks, including:
* **JavaScript/TypeScript:** Ethers.js, Viem
* **Go, Python, Java, Swift, Rust**
## Additional Resources
* [Tenderly Documentation](https://docs.tenderly.co/)
* [Sophon Documentation](https://docs.sophon.xyz/build/interact/sdks)
* [Tenderly Blog on Sophon Integration](https://blog.tenderly.co/creating-engaging-dapps-on-sophon-with-tenderly/)
By leveraging Tenderly’s tools, developers can enhance their workflow, improve contract reliability, and create high-quality dApps on the Sophon blockchain.
# Viem/Wagmi
Source: https://docs.sophon.xyz/build/interact/viem-wagmi
<Warning>
This guide is retained only for maintaining an existing Sophon v1 integration.
Do not start a new production integration on the chain.
</Warning>
The popular Viem + Wagmi frontend setup can be used with Sophon. This section will provide a working PoC repository, relevant code snippets, and some cool gotchas that will help you working with this stack.
<Check>
Check out our simple PoC [repository](https://github.com/sophon-org/hello-paymaster-wagmi-viem) that demonstrates how to use **Viem** and **Wagmi** together with the **Paymaster** .
</Check>
# Using `Viem` with a Paymaster
When building dApps on **Sophon**, it's important to correctly integrate our **Paymaster** to sponsor transactions, especially before **SOPH** is distributed.
This guide provides a working pattern, using `Viem` and `Wagmi`, for sending contract calls with Paymaster support on **Sophon**.
## ✅ Working Code Snippet
```ts theme={null}
"use client";
import { getAccount, getPublicClient, switchChain, writeContract } from "@wagmi/core";
import {
Abi,
AbiItemArgs,
Address,
createWalletClient,
custom,
encodeFunctionData,
Hash,
Hex,
} from "viem";
import { Config } from "Wagmi";
import { eip712WalletActions, getGeneralPaymasterInput } from "viem/zksync";
import { sophonTestnet, sophonMainnet } from "viem/chains";
export default async function sendTransaction(
wagmiConfig: Config,
chainId: number,
address: Address,
abi: Abi,
functionName: string,
args: AbiItemArgs,
value?: bigint
): Promise<Hash> {
const account = getAccount(wagmiConfig);
if (!account.address) throw new Error("No account connected.");
if (account.chainId !== chainId) await switchChain(wagmiConfig, { chainId });
const publicClient = getPublicClient(wagmiConfig, { chainId });
if (!publicClient) throw new Error("No public client available.");
const estimateGas = await publicClient.estimateContractGas({
account: account.address,
address,
abi,
functionName,
args,
value,
});
// const nextNonce = await publicClient.getTransactionCount({
// address: account.address,
// });
// Handle Sophon-specific logic
if (chainId === 50104 || chainId === 531050104) {
const walletClient = createWalletClient({
chain: chainId === 50104 ? sophonMainnet : sophonTestnet
transport: custom(window.ethereum!),
}).extend(eip712WalletActions());
const paymaster: Address = "0x98546B226dbbA8230cf620635a1e4ab01F6A99B2";
const paymasterInput: Hex = getGeneralPaymasterInput({
innerInput: "0x",
});
const txData = encodeFunctionData({ abi, functionName, args });
const hash = await walletClient.sendTransaction({
account: account.address,
to: address,
data: txData,
value,
gas: estimateGas,
chain,
paymaster,
paymasterInput,
// nonce: nextNonce, enable if you want to use a specific nonce
});
return hash;
}
// Fallback for non-ZKsync chains
return await writeContract(wagmiConfig, {
address,
chainId,
abi,
functionName,
args,
value,
gas: estimateGas,
});
}
```
## **⚠️ Key Gotchas to Watch Out For**
### **1. Missing paymasterInput or incorrect format**
`paymasterInput` **must** be passed, even if it’s an empty `0x` using:
```
getGeneralPaymasterInput({ innerInput: "0x" }).
```
<Warning>
Manually hardcoding `paymasterInput = "0x"` will not work.
</Warning>
### **2. Use ZKsync wallet extensions**
Extend your wallet client with `eip712WalletActions()` to support `sendTransaction` with Paymasters.
```typescript theme={null}
const walletClient = createWalletClient({
chain: sophonTestnet, // or `sophonMainnet`
transport: custom(window.ethereum!),
}).extend(eip712WalletActions());
```
### **3. Pre-calculating the nonce is possible, but optional**
Based on your personal use-cases, you can pre-calculate nonces, but this is also handled internally by Wagmi's `publicClient` **provider wrapper**.
```typescript theme={null}
const publicClient = getPublicClient(wagmiConfig, { chainId });
const nextNonce = await publicClient.getTransactionCount({
address: account.address,
});
const hash = await walletClient.sendTransaction({
account: account.address,
to: address,
data: txData,
value,
gas: estimateGas,
chain: sophonTestnet, // chain client that is connected
paymaster,
paymasterInput,
nonce: nextNonce,
});
```
# ZKsync CLI
Source: https://docs.sophon.xyz/build/interact/zksync-cli
<Warning>
This guide is retained only for maintaining an existing Sophon v1 deployment.
Do not start a new production deployment on the chain.
</Warning>
The [ZKsync CLI](https://github.com/matter-labs/zksync-cli) is a powerful tool designed to simplify the setup, development, testing, and deployment of contracts on ZK Chains. It also provides a way to scaffold dApps using templates leveraging various frontend and web3 libraries.
<Tip>**ZKsync CLI** is published on npm as [**`zksync-cli`**](https://www.npmjs.com/package/zksync-cli). Commands are invoked using `npx zksync-cli` in the terminal.</Tip>
<Note>
**Prerequisites**
* [Node.js v18 or higher](https://nodejs.org/en)
* [Git](https://git-scm.com/downloads)
* [Docker](https://www.docker.com/get-started/) (for `zksync-cli dev` commands)
</Note>
## Usage
You can run commands without installation: `npx zksync-cli` (For example: `npx zksync-cli dev start`).
## Available Commands
<Tip>To learn more about the available commands in ZKsync CLI, see the [**CLI reference**](https://docs.zksync.io/zksync-era/tooling/zksync-cli/reference).</Tip>
Here are the main command categories and their common use cases:
### Bridge
Transfer assets between L1 and L2.
```bash theme={null}
npx zksync-cli bridge deposit # Move funds from Ethereum (L1) to ZKsync (L2)
npx zksync-cli bridge withdraw # Initiate withdrawal from L2 to L1
npx zksync-cli bridge withdraw-finalize # Complete the withdrawal process to L1
```
### Config Chains
Manage custom chain configurations.
```bash theme={null}
npx zksync-cli config chains add # Add a new custom chain
npx zksync-cli config chains edit # Modify existing chain settings
```
### Contract
Interact with smart contracts.
```bash theme={null}
npx zksync-cli contract read # Execute read-only contract methods
npx zksync-cli contract write # Send transactions to contracts
npx zksync-cli contract encode # Generate calldata from contract methods
```
### Create
Bootstrap new projects using templates.
```bash theme={null}
npx zksync-cli create # Create new projects with various templates:
# - Frontend (Vue, React, Next.js, Nuxt, Vite)
# - Contracts (Hardhat with Solidity/Vyper)
# - Scripting (Node.js automation)
```
### Dev
Manage local development environment.
```bash theme={null}
npx zksync-cli dev start # Start local dev environment
npx zksync-cli dev clean # Clean data for configured modules
npx zksync-cli dev config # Select modules to run locally
```
### Transaction
Query transaction details.
```bash theme={null}
npx zksync-cli transaction info # Get detailed information about a transaction
```
### Wallet
Manage wallet operations.
```bash theme={null}
npx zksync-cli wallet balance # Check token balance for an address
npx zksync-cli wallet transfer # Send funds on L2 to another account
```
# Mainnet
Source: https://docs.sophon.xyz/build/mainnet
<Warning>
These contracts belong to the legacy Sophon Chain, which is being wound down.
They are retained for existing integrations and withdrawal support only. Do not
use the former `LzOftHelper` as a current bridge route; Sophon is no longer on
LayerZero.
</Warning>
### Chain Contracts
| Name | Address | Comment |
| - | - | - |
| BridgeHub Proxy | `0x303a465B659cBB0ab36eE643eA362c509EEb5213` ([link](https://etherscan.io/address/0x303a465B659cBB0ab36eE643eA362c509EEb5213)) | Acts as a hub for bridges, so that they have a single point of communication with all ZK chain contracts ([reference](https://docs.zksync.io/zk-stack/components/shared-bridges#components-bridgehub)) |
| Diamond Proxy | `0x05eDE6aD1f39B7A16C949d5C33a0658c9C7241e3` ([link](https://etherscan.io/address/0x05eDE6aD1f39B7A16C949d5C33a0658c9C7241e3)) | The main contract uses [EIP-2535](https://eips.ethereum.org/EIPS/eip-2535) diamond proxy pattern ([reference](https://docs.zksync.io/build/developer-reference/era-contracts/l1-contracts#diamondproxy)) |
| Governance | `0xE1eeA4D6443b19D373Fe99De838b930Ef0ac2Ad3` ([link](https://etherscan.io/address/0xE1eeA4D6443b19D373Fe99De838b930Ef0ac2Ad3)) | Deployer and Admin multi-sig for ZK chains |
| Shared Bridge | L1: `0xD7f9f54194C633F36CCD5F3da84ad4a1c38cB2cB` ([link](https://etherscan.io/address/0xD7f9f54194C633F36CCD5F3da84ad4a1c38cB2cB))<br />L2: `0x954ba8223a6BFEC1Cc3867139243A02BA0Bc66e4` ([link](https://explorer.sophon.xyz/address/0x954ba8223a6BFEC1Cc3867139243A02BA0Bc66e4)) | Bridges assets between L1 and hyperchains, supporting both ETH and ERC20 tokens ([reference](https://docs.zksync.io/zk-stack/components/shared-bridges)) |
| Verifier | `0xc2eE6b6af7d616f6e27ce7F4A451Aedc2b0F5f5C` ([link](https://etherscan.io/address/0xc2eE6b6af7d616f6e27ce7F4A451Aedc2b0F5f5C)) | ZK proof verifier contract |
### Useful Contracts
| Name | Address | Comment |
| - | - | - |
| Sophon Global Paymaster | L2: `0x98546B226dbbA8230cf620635a1e4ab01F6A99B2` ([link](https://explorer.sophon.xyz/address/0x98546B226dbbA8230cf620635a1e4ab01F6A99B2)) | Sponsors all transactions |
| Multicall | `0x5f4867441d2416cA88B1b3fd38f21811680CD2C8` ([link](https://explorer.sophon.xyz/address/0x5f4867441d2416cA88B1b3fd38f21811680CD2C8)) | Enables more efficient contract querying: [https://github.com/mds1/multicall](https://github.com/mds1/multicall) |
| Disperse | `0x7853Fa386191EF961e6448dEBE4C3E205F7A4215` ([link](https://explorer.sophon.xyz/address/0x7853Fa386191EF961e6448dEBE4C3E205F7A4215)) | Enables batch transfers for tokens and SOPH : [https://github.com/sophon-org/disperse](https://github.com/sophon-org/disperse) |
| TimestampAsserter | `0x3070e0Ff401098d250D78D4aeAF6fC85C6bD29ff` ([link](https://explorer.sophon.xyz/address/0x3070e0Ff401098d250D78D4aeAF6fC85C6bD29ff)) | Verifies if the current block timestamp falls within a specified range |
| Permit2 | `0xb8e9B994102309E820cf29BA0D98673C8995Ebad` ([link](https://explorer.sophon.xyz/address/0xb8e9B994102309E820cf29BA0D98673C8995Ebad)) | Makes token approvals easier and more secure: [https://github.com/Uniswap/permit2](https://github.com/Uniswap/permit2) |
| LzOftHelper (retired) | `0x88172F3041Bd0787520dbc9Bd33D3d48e1fb46dc` | Legacy contract; Sophon is no longer connected to LayerZero. Do not use it for new transfers. |
| Seaport 1.6 | `0x18f4D8BbEE9F8783E17B7f2F3Cc18c9Be346ba44` ([link](https://explorer.sophon.xyz/address/0x18f4D8BbEE9F8783E17B7f2F3Cc18c9Be346ba44)) | OpenSea's marketplace protocol for safely and efficiently buying and selling NFTs |
| Conduit Controller | `0x0E5267441f3dC4BEC3bbC7f0e6588239c76C1B75` ([link](https://explorer.sophon.xyz/address/0x0E5267441f3dC4BEC3bbC7f0e6588239c76C1B75)) | Protocol component for Seaport that manages token transfers |
### Tokens
| Asset | Address | L1 Address |
| - | - | - |
| ETH | `0x72af9F169B619D85A47Dfa8fefbCD39dE55c567D` ([link](https://explorer.sophon.xyz/address/0x72af9F169B619D85A47Dfa8fefbCD39dE55c567D)) | `0x0000000000000000000000000000000000000000` ([link](https://etherscan.io/address/0x0000000000000000000000000000000000000000)) |
| SOPH | `0x000000000000000000000000000000000000800A` ([link](https://explorer.sophon.xyz/address/0x000000000000000000000000000000000000800A)) | `0x6B7774CB12ed7573a7586E7D0e62a2A563dDd3f0` ([link](https://etherscan.io/token/0x6B7774CB12ed7573a7586E7D0e62a2A563dDd3f0)) |
| WSOPH | `0x2b1A859dE6A55c553520D7780Bc5805712B128F9` ([link](https://explorer.sophon.xyz/address/0x2b1A859dE6A55c553520D7780Bc5805712B128F9)) | N/A |
| vSOPH | `0xe1A376fa16f40A1dc3712463616054e6CCA338ED` ([link](https://explorer.sophon.xyz/address/0xe1A376fa16f40A1dc3712463616054e6CCA338ED)) | N/A |
| BEAM | `0x7A94dFb534ec790277Ad332EFB9B11687A130880` ([link](https://explorer.sophon.xyz/address/0x7A94dFb534ec790277Ad332EFB9B11687A130880)) | `0x62d0a8458ed7719fdaf978fe5929c6d342b0bfce` ([link](https://etherscan.io/address/0x62d0a8458ed7719fdaf978fe5929c6d342b0bfce)) |
| stZENT | `0x351ca00C5B64C03CA6d1eB9ABe5355ed449ac19C` ([link](https://explorer.sophon.xyz/address/0x351ca00C5B64C03CA6d1eB9ABe5355ed449ac19C)) | `0x996d67aa9b37df96428ad3608cb21352bf1fdb90` ([link](https://etherscan.io/address/0x996d67aa9b37df96428ad3608cb21352bf1fdb90)) |
| stATH | `0x42E5bFdC7032D1F8e4B4D3fea3Eb5dB9C01Ef997` ([link](https://explorer.sophon.xyz/address/0x42E5bFdC7032D1F8e4B4D3fea3Eb5dB9C01Ef997)) | `0xc96aa65f31e41b4ca6924b86d93e25686019e59c` ([link](https://etherscan.io/address/0xc96aa65f31e41b4ca6924b86d93e25686019e59c)) |
| PEPE | `0x06432e41131B70708c1C46814c2fcE9e720edd8A` ([link](https://explorer.sophon.xyz/address/0x06432e41131B70708c1C46814c2fcE9e720edd8A)) | `0x6982508145454Ce325dDbE47a25d4ec3d2311933` ([link](https://etherscan.io/address/0x6982508145454Ce325dDbE47a25d4ec3d2311933)) |
| USDT | `0x6386dA73545ae4E2B2E0393688fA8B65Bb9a7169` ([link](https://explorer.sophon.xyz/address/0x6386dA73545ae4E2B2E0393688fA8B65Bb9a7169)) | `0xdac17f958d2ee523a2206206994597c13d831ec7` ([link](https://etherscan.io/address/0xdac17f958d2ee523a2206206994597c13d831ec7)) |
| USDC | `0x9Aa0F72392B5784Ad86c6f3E899bCc053D00Db4F` ([link](https://explorer.sophon.xyz/address/0x9Aa0F72392B5784Ad86c6f3E899bCc053D00Db4F)) | `0xac85cda0c91d5571e79deac9ecef6fa90978bb5b` ([link](https://etherscan.io/address/0xac85cda0c91d5571e79deac9ecef6fa90978bb5b)) |
| wstETH | `0x60D02F185F80644e1A5ae35497736dd31d1b078B` ([link](https://explorer.sophon.xyz/address/0x60D02F185F80644e1A5ae35497736dd31d1b078B)) | `0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0` ([link](https://etherscan.io/address/0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0)) |
| weETH | `0x5E9Fc50b44988B66BA84500f8Bc32C0493fe8F8D` ([link](https://explorer.sophon.xyz/address/0x5E9Fc50b44988B66BA84500f8Bc32C0493fe8F8D)) | `0xcd5fe23c85820f7b72d0926fc9b05b43e359b7ee` ([link](https://etherscan.io/address/0xcd5fe23c85820f7b72d0926fc9b05b43e359b7ee)) |
| sDAI | `0xeCcbb9360d235548473Cb8C752735F68e652439B` ([link](https://explorer.sophon.xyz/address/0xeCcbb9360d235548473Cb8C752735F68e652439B)) | `0x83f20f44975d03b1b09e64809b757c47f942beea` ([link](https://etherscan.io/address/0x83f20f44975d03b1b09e64809b757c47f942beea)) |
| DAI | `0x88171a5BbAcd92ca5e25575c5904581C80B025Dd` ([link](https://explorer.sophon.xyz/address/0x88171a5BbAcd92ca5e25575c5904581C80B0프로젝트로 돌아가기