接口进展:https://docs.google.com/spreadsheets/d/1I6n8siwklm3lKz7PO57B0Hf7v9P_FStgmPip30Eyqlc/edit#gid=0 ## eth_syncing 1. 功能:查询节点同步信息 2. 参数:`null` 3. 返回值 ``` false:不在同步 { startBlock: import启动时的高度 currentBlock: 当前块高,eth_blockNumber一样 highestBlock: 估计的最高块 } ``` 4. API server 1. 读取indexer同步的信息 2. 直接读取Godwoken接口 5. Godwoken提供接口 ``` lastSynced(): Promise<HexString> 只提供currentBlock信息 syncing(): Promise<SyncStatus> ``` ## eth_gasPrice 1. 功能:查询gasPrice 2. 参数:`null` 3. 返回值 ``` gasPrice: hex num in wei ``` 4. API server 1. 参考geth,通过过去N个块的gasPrice中位数 2. 参考gasNow,读取txpool里面pendingTransaction的gasPrice 5. Godwoken提供接口 ``` gasPrice(): Promise<HexNumber>; ``` ## eth_getBalance 1. 功能:查询地址的原生代币的额度 2. 参数 ``` address: hex string, blockParameter: hex num, or {"latest","earliest", "pending"},默认latest,指定块高需要archive mode支持 ``` 3. 返回值 ``` balance: hex num in wei ``` 4. API server 将ethAddress转换成accountId: address -> script -> scriptHash -> accountId; 根据accountId和sudtId读取balance; 5. Godwoken提供接口 ``` getAccountIdByScriptHash(scriptHash): Promise<number> getBalance(accountId, sudtId, [blockParameter]): Promise<HexNumer> ``` ## eth_getStorageAt 1. 功能:查询合约的状态存储 2. 参数 ``` address: hex string, storagePosition: hex string, blockParameter: hex num, or {"latest","earliest", "pending"},默认latest,指定块高需要archive mode支持 ``` 3. 返回值 ``` storageValue: hex string ``` 4. API server 将ethAddress转换成accountId: address -> script -> scriptHash -> accountId; storagePosition计算规则: 1. ethereum中,分为基础类型/map类型,计算key 2. godwoken中,状态的rawKey计算 5. Godwoken提供接口 ``` getAccountIdByScriptHash(scriptHash): Promise<number> getStorageAt(accountId, rawKey, [blockParameter]): Promise<Hash> ``` ## eth_getTransactionCount 1. 功能:查询地址发送出的交易数量(nonce) 2. 参数 ``` address: hex string, blockParameter: hex num, or {"latest","earliest", "pending"},默认latest,指定块高需要archive mode支持 ``` 3. 返回值 ``` count: hex num ``` 4. API server 将ethAddress转换成accountId: address -> script -> scriptHash -> accountId; 5. Godwoken提供接口 ``` getAccountIdByScriptHash(scriptHash): Promise<number> getTransactionCount(accountId, [blockParameter]): Promise<number> ``` ## eth_getCode 1. 功能:读取合约代码 2. 参数 ``` address: hex string, blockParameter: hex num, or {"latest","earliest", "pending"},默认latest,指定块高需要archive mode支持 ``` 3. 返回值 ``` code: hex string, EOA账户返回"0x" ``` 4. API server 将ethAddress转换成accountId: address -> script -> scriptHash -> accountId; 5. Godwoken提供接口 ``` getAccountIdByScriptHash(scriptHash): Promise<number>; getCode(accountId, [blockParameter]): Promise<HexString> ``` ## eth_call 1. 功能:节点执行message call,交易不上链 2. 参数 ``` from: hex string, to: hex string, gas: hex number, gasPrice: hex number, value: hex number, data: hex string, blockParameter: hex num, or {"latest","earliest", "pending"},默认latest,指定块高需要archive mode支持 ``` 3. 返回值 ``` returnValue: hex string errorMsg: REVERT ``` 4. API server 构造RawL2Transaction; 从RunResult中提取returnValue; 5. Godwoken提供接口 ``` call(RawL2Transaction): Promise<RunResult> ``` ## eth_estimateGas 1. 功能:节点执行message call,估计花费的gas 2. 参数 ``` from: hex string, to: hex string, gas: hex number, gasPrice: hex number, value: hex number, data: hex string, blockParameter: hex num, or {"latest","earliest", "pending"},默认latest,指定块高需要archive mode支持 ``` 3. 返回值 ``` returnValue: hex string errorMsg: REVERT ``` 4. API server 构造RawL2Transaction; 从RunResult中提取estimateGas; 5. Godwoken提供接口 ``` call(RawL2Transaction): Promise<RunResult> ``` ## Filter过滤器 ### eth_newBlockFilter ### eth_newPendingTransactionFilter ## WSS subscribe ### subscribe ### unsubscribe
接口进展:https://docs.google.com/spreadsheets/d/1I6n8siwklm3lKz7PO57B0Hf7v9P_FStgmPip30Eyqlc/edit#gid=0
eth_syncing
功能:查询节点同步信息
参数:
null返回值
API server
Godwoken提供接口
eth_gasPrice
功能:查询gasPrice
参数:
null返回值
API server
Godwoken提供接口
eth_getBalance
功能:查询地址的原生代币的额度
参数
返回值
API server
将ethAddress转换成accountId: address -> script -> scriptHash -> accountId;
根据accountId和sudtId读取balance;
Godwoken提供接口
eth_getStorageAt
功能:查询合约的状态存储
参数
返回值
API server
将ethAddress转换成accountId: address -> script -> scriptHash -> accountId;
storagePosition计算规则:
Godwoken提供接口
eth_getTransactionCount
功能:查询地址发送出的交易数量(nonce)
参数
返回值
API server
将ethAddress转换成accountId: address -> script -> scriptHash -> accountId;
Godwoken提供接口
eth_getCode
功能:读取合约代码
参数
返回值
API server
将ethAddress转换成accountId: address -> script -> scriptHash -> accountId;
Godwoken提供接口
eth_call
功能:节点执行message call,交易不上链
参数
返回值
API server
构造RawL2Transaction;
从RunResult中提取returnValue;
Godwoken提供接口
eth_estimateGas
功能:节点执行message call,估计花费的gas
参数
返回值
API server
构造RawL2Transaction;
从RunResult中提取estimateGas;
Godwoken提供接口
Filter过滤器
eth_newBlockFilter
eth_newPendingTransactionFilter
WSS subscribe
subscribe
unsubscribe