一套 SDK 調通 Solon 全部能力:行情、交易、股息、認購、跨鏈橋、合規身份。JavaScript 開箱即用,Python SDK 與 6 個示例工程隨主網交付。
<!-- 1. 引入 ethers + Solon SDK --> <script src="https://solon.digital/assets/ethers.umd.min.js"></script> <script src="https://solon.digital/assets/solon-defi.js"></script> <script src="https://solon.digital/assets/solon-sdk.js"></script> // 2. 連接(只讀模式可不傳私鑰) const sdk = new SolonSDK(); await sdk.connect('0x你的私鑰'); // 或 sdk.connectProvider(window.ethereum) // 3. 查價 → 買入 10 SLN 的 NVDA 通證 await sdk.price('NVDA'); // 145.0(SLN 計) await sdk.buy('NVDA', '10'); // 鏈上原子成交
| 參數 | 值 |
|---|---|
| 網絡名稱 | Solon Chain Testnet |
| Chain ID | 51051(0xC78B) |
| 公開 RPC | https://solon.digital/solonrpc/ |
| 原生代幣 | SLN(18 位精度,Gas 用) |
| 區塊瀏覽器 | solon.digital/explorer |
| 測試水龍頭 | solon.digital/faucet(每次 100 SLN) |
| 出塊時間 | ~3 秒(主網目標亞秒級) |
| 通證標準 | ERC-3643 兼容證券通證(碎股 18 位、凍結/找回、合規規則引擎) |
| 端點 | 説明 |
|---|---|
| GET /api/v1/status | 鏈狀態:高度、出塊間隔、Gas、節點 peer 數 |
| GET /api/v1/markets | 全部通證行情:預言機價、24h 成交額與筆數 |
| GET /api/v1/tokens/{SYM}/quote | 單通證報價 + AMM 雙向試算(1 SLN 可買 / 1 股可賣) |
| GET /api/v1/tokens/{SYM}/trades?limit=50 | 近期成交流(方向、數量、對手地址、tx 哈希) |
| GET /api/v1/tokens/{SYM}/holders | 持有人名冊(逐筆回算,含佔比,5 分鐘緩存) |
| GET /api/v1/tokens/{SYM}/candles | K 線 OHLCV(15m / 1h / 4h,Swap 事件聚合) |
| GET /api/explorer/api?module=account&action=… | Etherscan 兼容:balance / tokenbalance / tokentx |
# 任何語言零依賴直連(示例:curl / Python requests)
curl https://solon.digital/api/v1/markets
import requests
m = requests.get('https://solon.digital/api/v1/markets').json()
print([(x['symbol'], x['priceSln']) for x in m['markets']])
| 端點 | 説明 |
|---|---|
| GET /api/v1/pro/settlement | 日終結算報告:24h 全市場成交量/筆數、分通證彙總、獨立交易方、Top 5 交易方 |
# HMAC 簽名調用(bash + openssl 零依賴)
TS=$(date +%s); KEY=sk_demo_solon_001; SECRET=whsec_demo_7f3a9c2e5b
SIGN=$(printf "%s:%s" "$TS" "$KEY" | openssl dgst -sha256 -hmac "$SECRET" | awk '{print $2}')
curl -H "x-api-key: $KEY" -H "x-api-ts: $TS" -H "x-api-sign: $SIGN" \
https://solon.digital/api/v1/pro/settlement
| 分組 | 方法 | 説明 |
|---|---|---|
| 行情 | price(sym) · prices() · quoteBuy(sym, sln) · quoteSell(sym, shares) | 預言機價格與 AMM 買賣試算 |
| 交易 | buy(sym, sln) · sell(sym, shares) | AMM 市價單,碎股最小 0.000001 股 |
| 限價 | placeBuy / placeSell(sym, price, shares) · cancelOrder(id) | 鏈上限價訂單簿,託管自動退還 |
| 股息 | dividends() · claimable(divId) · claimDividend(divId) | 快照分派、一鍵領取 |
| 認購 | offers() · subscribe(offerId, amount) | 一級市場申購,DvP 原子交收 |
| 跨鏈橋 | bridgeDeposit(sln, chainId, target) · bridgeClaim(id) | 鎖定 / 領取,進度鏈上可查 |
| 賬户 | balanceSLN() · balanceOf(sym) · isVerified() · registerSelf() | 餘額、持倉與 KYC 身份 |
遍歷全部股票通證,一次拿全預言機價格。
const sdk = new SolonSDK();
console.log(await sdk.prices());
// { NVDA: 145, AAPL: 230, TSLA: 420, … }↓ 下載完整示例文件轉賬前檢查雙方 KYC,避免鏈上回滾。
const ok = await sdk.isVerified(toAddr);
if (!ok) throw new Error('收款方未通過 KYC');
// 通過後再調用通證 transfer↓ 下載完整示例文件遍歷分派批次,把可領的一次領完。
for (const d of await sdk.dividends()) {
if (await sdk.claimable(d.id) > 0)
await sdk.claimDividend(d.id);
}↓ 下載完整示例文件讀取在售發行,按份額申購(DvP 交收)。
const [offer] = await sdk.offers(); await sdk.subscribe(offer.id ?? 1, '100'); // 100 份 GLD,資金與通證原子交收↓ 下載完整示例文件
鎖定 SLN 到橋合約,中繼確認後自助領取。
await sdk.bridgeDeposit('50', 11155111, myAddr);
// 進度查詢:bridge.getXfer(id)↓ 下載完整示例文件掛買單後監聽成交,超時自動撤銷。
await sdk.placeBuy('NVDA', '140', '5');
// … 10 分鐘未成交:
await sdk.cancelOrder(orderId); // 託管 SLN 自動退還↓ 下載完整示例文件· Python SDK 與 TypeScript SDK 均已提供下載(web3.py / ethers v6,方法與 JS 版全對齊);viem 封裝版隨主網交付。
· 機構 API(REST + WebSocket,API Key + HMAC 簽名 + IP 白名單)在階段二開放申請,端點清單見開發者文檔。
· 所有合約地址與 ABI 已內置在 solon-defi.js(JS)與 assets/abi/*.json(Python),隨 SDK 自動加載,無需手工配置。