deploy-to-skale

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Deploy to SKALE

部署到SKALE

This guide covers deploying smart contracts to SKALE chains.
本指南介绍如何将智能合约部署到SKALE链。

Chain Selection

链选择

Default: SKALE Base (Recommended)

默认:SKALE Base(推荐)

NetworkChain IDRPCExplorer
Testnet324705682
https://base-sepolia-testnet.skalenodes.com/v1/jubilant-horrible-ancha
https://base-sepolia-testnet-explorer.skalenodes.com/
Mainnet1187947933
https://skale-base.skalenodes.com/v1/base
https://skale-base-explorer.skalenodes.com/
网络链IDRPC区块浏览器
测试网324705682
https://base-sepolia-testnet.skalenodes.com/v1/jubilant-horrible-ancha
https://base-sepolia-testnet-explorer.skalenodes.com/
主网1187947933
https://skale-base.skalenodes.com/v1/base
https://skale-base-explorer.skalenodes.com/

Ethereum-connected

以太坊连接链

ChainChain IDRPCExplorer
Europa Hub2046399126
https://mainnet.skalenodes.com/v1/elated-tan-skat
https://elated-tan-skat.explorer.mainnet.skalenodes.com/
Calypso Hub1564830818
https://mainnet.skalenodes.com/v1/honorable-steel-rasalhague
https://honorable-steel-rasalhague.explorer.mainnet.skalenodes.com/
Nebula Hub1482601649
https://mainnet.skalenodes.com/v1/green-giddy-denebola
https://green-giddy-denebola.explorer.mainnet.skalenodes.com/
链名称链IDRPC区块浏览器
Europa Hub2046399126
https://mainnet.skalenodes.com/v1/elated-tan-skat
https://elated-tan-skat.explorer.mainnet.skalenodes.com/
Calypso Hub1564830818
https://mainnet.skalenodes.com/v1/honorable-steel-rasalhague
https://honorable-steel-rasalhague.explorer.mainnet.skalenodes.com/
Nebula Hub1482601649
https://mainnet.skalenodes.com/v1/green-giddy-denebola
https://green-giddy-denebola.explorer.mainnet.skalenodes.com/

Gas Models

Gas模型

  • SKALE Base: Compute Credits (prepaid)
  • Others: sFUEL (~0 cost)
  • SKALE Base: 计算积分(预付费)
  • 其他: sFUEL(几乎零成本)

Deployment

部署

Foundry

Foundry

bash
undefined
bash
undefined

Install Foundry if needed

Install Foundry if needed

curl -L https://foundry.paradigm.xyz | bash foundryup
curl -L https://foundry.paradigm.xyz | bash foundryup

Install SKALE RNG library

Install SKALE RNG library

forge install dirtroad/skale-rng
forge install dirtroad/skale-rng

Deploy

Deploy

forge script script/Deploy.s.sol
--rpc-url $SKALE_RPC
--private-key $PRIVATE_KEY
--legacy
--broadcast
undefined
forge script script/Deploy.s.sol
--rpc-url $SKALE_RPC
--private-key $PRIVATE_KEY
--legacy
--broadcast
undefined

Hardhat

Hardhat

typescript
// hardhat.config.ts
const config: HardhatUserConfig = {
    networks: {
        skaleBaseSepolia: {
            url: process.env.SKALE_RPC,
            chainId: 324705682,
            accounts: [process.env.PRIVATE_KEY]
        },
        skaleBase: {
            url: process.env.SKALE_RPC,
            chainId: 1187947933,
            accounts: [process.env.PRIVATE_KEY]
        }
    },
    solidity: { version: "0.8.27" }
};

export default config;
bash
npx hardhat run scripts/deploy.ts --network skaleBaseSepolia
typescript
// hardhat.config.ts
const config: HardhatUserConfig = {
    networks: {
        skaleBaseSepolia: {
            url: process.env.SKALE_RPC,
            chainId: 324705682,
            accounts: [process.env.PRIVATE_KEY]
        },
        skaleBase: {
            url: process.env.SKALE_RPC,
            chainId: 1187947933,
            accounts: [process.env.PRIVATE_KEY]
        }
    },
    solidity: { version: "0.8.27" }
};

export default config;
bash
npx hardhat run scripts/deploy.ts --network skaleBaseSepolia

CTX Contracts (Conditional Transactions)

CTX合约(条件交易)

Requires:
  • Solidity >=0.8.27
  • EVM istanbul
toml
undefined
依赖要求:
  • Solidity >=0.8.27
  • EVM istanbul
toml
undefined

foundry.toml

foundry.toml

solc_version = "0.8.27" evm_version = "istanbul"
undefined
solc_version = "0.8.27" evm_version = "istanbul"
undefined

RNG (Random Numbers)

RNG(随机数生成)

Native random via precompile at
0x18
:
solidity
import "@dirtroad/skale-rng/contracts/RNG.sol";

contract MyContract is RNG {
    function random() external view returns (uint256) {
        return getRandomNumber();
    }
    
    function randomRange(uint256 min, uint256 max) external view returns (uint256) {
        return getNextRandomRange(min, max);
    }
}
Notes:
  • RNG is native to SKALE (relies on SKALE Consensus)
  • On local testing or other chains, returns 0
  • Multiple calls in same block return same value
通过地址为
0x18
的预编译合约实现原生随机数:
solidity
import "@dirtroad/skale-rng/contracts/RNG.sol";

contract MyContract is RNG {
    function random() external view returns (uint256) {
        return getRandomNumber();
    }
    
    function randomRange(uint256 min, uint256 max) external view returns (uint256) {
        return getNextRandomRange(min, max);
    }
}
注意事项:
  • RNG是SKALE原生功能(依赖SKALE共识)
  • 在本地测试环境或其他链上运行时返回0
  • 同一区块内多次调用返回相同值

Bridge

桥接

Token Bridge

代币桥接

typescript
const token = new Contract(tokenAddress, ERC20_ABI, signer);
const bridge = new Contract(bridgeAddress, BRIDGE_ABI, signer);

await token.approve(bridgeAddress, amount);
await bridge.depositERC20(tokenAddress, amount, targetChain, receiver);
typescript
const token = new Contract(tokenAddress, ERC20_ABI, signer);
const bridge = new Contract(bridgeAddress, BRIDGE_ABI, signer);

await token.approve(bridgeAddress, amount);
await bridge.depositERC20(tokenAddress, amount, targetChain, receiver);

IMA Messaging

IMA消息传递

MessageProxy:
0xd2AAa00100000000000000000000000000000000
MessageProxy地址:
0xd2AAa00100000000000000000000000000000000

x402 (AI Agent Payments)

x402(AI Agent支付)

For x402 payments, see
x402-on-skale
skill.
Quick setup:
bash
npm install @x402/core @x402/evm @x402/hono
typescript
import { paymentMiddleware, x402ResourceServer } from "@x402/hono";
import { HTTPFacilitatorClient } from "@x402/core/server";

const client = new HTTPFacilitatorClient({ url: "https://facilitator.payai.network" });
const server = new x402ResourceServer(client);

app.use(paymentMiddleware({
    "GET /api/premium": {
        accepts: [{
            scheme: "exact",
            network: "eip155:324705682",
            payTo: "0xYourAddress",
            price: { 
                amount: "10000",
                asset: "0x2e08028E3C4c2356572E096d8EF835cD5C6030bD"
            }
        }]
    }
}, server));
Payment tokens:
  • Bridged USDC:
    0x2e08028E3C4c2356572E096d8EF835cD5C6030bD
  • Axios USD:
    0x61a26022927096f444994dA1e53F0FD9487EAfcf
x402支付相关内容请参考
x402-on-skale
技能。
快速配置:
bash
npm install @x402/core @x402/evm @x402/hono
typescript
import { paymentMiddleware, x402ResourceServer } from "@x402/hono";
import { HTTPFacilitatorClient } from "@x402/core/server";

const client = new HTTPFacilitatorClient({ url: "https://facilitator.payai.network" });
const server = new x402ResourceServer(client);

app.use(paymentMiddleware({
    "GET /api/premium": {
        accepts: [{
            scheme: "exact",
            network: "eip155:324705682",
            payTo: "0xYourAddress",
            price: { 
                amount: "10000",
                asset: "0x2e08028E3C4c2356572E096d8EF835cD5C6030bD"
            }
        }]
    }
}, server));
支付代币:
  • 桥接USDC:
    0x2e08028E3C4c2356572E096d8EF835cD5C6030bD
  • Axios USD:
    0x61a26022927096f444994dA1e53F0FD9487EAfcf

BITE (Privacy)

BITE(隐私)

For encrypted transactions, see
build-with-bite
skill.
Key points:
  • Gas: Always set manually (300k default)
  • estimateGas doesn't work with BITE
  • Chains: SKALE Base, SKALE Base Sepolia
Reference: Docs
加密交易相关内容请参考
build-with-bite
技能。
核心要点:
  • Gas:始终手动设置(默认300k)
  • estimateGas不支持BITE
  • 支持链:SKALE Base、SKALE Base Sepolia
参考:文档