deploy-to-skale
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDeploy to SKALE
部署到SKALE
This guide covers deploying smart contracts to SKALE chains.
本指南介绍如何将智能合约部署到SKALE链。
Chain Selection
链选择
Default: SKALE Base (Recommended)
默认:SKALE Base(推荐)
| Network | Chain ID | RPC | Explorer |
|---|---|---|---|
| Testnet | 324705682 | | |
| Mainnet | 1187947933 | | |
| 网络 | 链ID | RPC | 区块浏览器 |
|---|---|---|---|
| 测试网 | 324705682 | | |
| 主网 | 1187947933 | | |
Ethereum-connected
以太坊连接链
| Chain | Chain ID | RPC | Explorer |
|---|---|---|---|
| Europa Hub | 2046399126 | | |
| Calypso Hub | 1564830818 | | |
| Nebula Hub | 1482601649 | | |
| 链名称 | 链ID | RPC | 区块浏览器 |
|---|---|---|---|
| Europa Hub | 2046399126 | | |
| Calypso Hub | 1564830818 | | |
| Nebula Hub | 1482601649 | | |
Gas Models
Gas模型
- SKALE Base: Compute Credits (prepaid)
- Others: sFUEL (~0 cost)
- SKALE Base: 计算积分(预付费)
- 其他: sFUEL(几乎零成本)
Deployment
部署
Foundry
Foundry
bash
undefinedbash
undefinedInstall 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
--rpc-url $SKALE_RPC
--private-key $PRIVATE_KEY
--legacy
--broadcast
undefinedforge script script/Deploy.s.sol
--rpc-url $SKALE_RPC
--private-key $PRIVATE_KEY
--legacy
--broadcast
--rpc-url $SKALE_RPC
--private-key $PRIVATE_KEY
--legacy
--broadcast
undefinedHardhat
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 skaleBaseSepoliatypescript
// 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 skaleBaseSepoliaCTX Contracts (Conditional Transactions)
CTX合约(条件交易)
Requires:
- Solidity >=0.8.27
- EVM istanbul
toml
undefined依赖要求:
- Solidity >=0.8.27
- EVM istanbul
toml
undefinedfoundry.toml
foundry.toml
solc_version = "0.8.27"
evm_version = "istanbul"
undefinedsolc_version = "0.8.27"
evm_version = "istanbul"
undefinedRNG (Random Numbers)
RNG(随机数生成)
Native random via precompile at :
0x18solidity
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
通过地址为的预编译合约实现原生随机数:
0x18solidity
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:
0xd2AAa00100000000000000000000000000000000MessageProxy地址:
0xd2AAa00100000000000000000000000000000000x402 (AI Agent Payments)
x402(AI Agent支付)
For x402 payments, see skill.
x402-on-skaleQuick setup:
bash
npm install @x402/core @x402/evm @x402/honotypescript
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/honotypescript
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 skill.
build-with-biteKey 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
参考:文档