您正在查看: Surou 发布的文章
简单的以太坊API以获取您的ERC20代币余额以及有用的信息
https://github.com/hunterlong/tokenbalance
import (
"github.com/hunterlong/tokenbalance"
)
func main() {
// connect to your Geth Server
configs = &tokenbalance.Config{
GethLocation: "https://eth.coinapp.io",
Logs: true,
}
configs.Connect()
// insert a Token Contract address and Wallet address
contract := "0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0"
wallet := "0xbfaa1a1ea534d35199e84859975648b59880f639"
// query the blockchain and wallet details
token, err := tokenbalance.New(contract, wallet)
// Token Balance will respond back useful things
token.BalanceString() // "600000.0"
token.ETHString() // "1.020095885777777767"
token.Name // "OmiseGO"
token.Symbol // "OMG"
token.Decimals // 18
token.Balance // big.Int() (token balance)
token.ETH // big.Int() (ether balance)
}
Ethereum HD Wallet derivations in Go
https://github.com/miguelmota/go-ethereum-hdwallet.git
Install
go get -u github.com/miguelmota/go-ethereum-hdwallet
Documenation
https://godoc.org/github.com/miguelmota/go-ethereum-hdwallet
Getting started
package main
import (
"fmt"
"log"
"github.com/miguelmota/go-ethereum-hdwallet"
)
func main() {
mnemonic := "tag volcano eight thank tide danger coast health above argue embrace heavy"
wallet, err := hdwallet.NewFromMnemonic(mnemonic)
if err != nil {
log.Fatal(err)
}
path := hdwallet.MustParseDerivationPath("m/44'/60'/0'/0/0")
account, err := wallet.Derive(path, false)
if err != nil {
log.Fatal(err)
}
fmt.Println(account.Address.Hex()) // 0xC49926C4124cEe1cbA0Ea94Ea31a6c12318df947
path = hdwallet.MustParseDerivationPath("m/44'/60'/0'/0/1")
account, err = wallet.Derive(path, false)
if err != nil {
log.Fatal(err)
}
fmt.Println(account.Address.Hex()) // 0x8230645aC28A4EdD1b0B53E7Cd8019744E9dD559
}
Signing transaction
package main
import (
"log"
"math/big"
"github.com/davecgh/go-spew/spew"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/miguelmota/go-ethereum-hdwallet"
)
func main() {
mnemonic := "tag volcano eight thank tide danger coast health above argue embrace heavy"
wallet, err := hdwallet.NewFromMnemonic(mnemonic)
if err != nil {
log.Fatal(err)
}
path := hdwallet.MustParseDerivationPath("m/44'/60'/0'/0/0")
account, err := wallet.Derive(path, true)
if err != nil {
log.Fatal(err)
}
nonce := uint64(0)
value := big.NewInt(1000000000000000000)
toAddress := common.HexToAddress("0x0")
gasLimit := uint64(21000)
gasPrice := big.NewInt(21000000000)
var data []byte
tx := types.NewTransaction(nonce, toAddress, value, gasLimit, gasPrice, data)
signedTx, err := wallet.SignTx(account, tx, nil)
if err != nil {
log.Fatal(err)
}
spew.Dump(signedTx)
}
CLI
go get -u github.com/miguelmota/go-ethereum-hdwallet/cmd/geth-hdwallet
$ geth-hdwallet -mnemonic "tag volcano eight thank tide danger coast health above argue embrace heavy" -path "m/44'/60'/0'/0/0"
public address: 0xC49926C4124cEe1cbA0Ea94Ea31a6c12318df947
private key: 63e21d10fd50155dbba0e7d3f7431a400b84b4c2ac1ee38872f82448fe3ecfb9
Test
make test
弹性的以太坊事件监听器,可将您的智能合约事件和后端微服务联系起来
https://github.com/eventeum/eventeum
以太坊事件监听器,将您的智能合约事件和后端微服务联系起来。Eventeum侦听以太坊网络发出的特定事件,并将这些事件广播到您的中间件层。这提供了不同的关注点分离,并且意味着您的微服务不必直接将事件订阅到以太坊节点。
eth poa 链加油站gasprice
部署安装
git clone https://github.com/bcskill/eth-gasprices.git
cd eth-gasprices
pip3 install -r requirements.txt
服务运行
export ETH_RPC_URL=http://ip:8545
python3 gasprice.py -h 0.0.0.0 -p 8000
服务启动
cp gasprice.service /etc/systemd/system/gasprice.service
systemctl daemon-reload
systemctl start gasprice.service
systemctl status gasprice.service
或者
python3 gasprice.py -h 0.0.0.0 -p 8000 "$@" > ./stdout.txt 2> ./stderr.txt & echo $! > ./nodeos.pid
tail -f stderr.txt
测试访问
测试数据
{
"health": true,
"block_number": 26972,
"block_time": 2.261,
"slow": 24,
"standard": 25,
"fast": 54.955,
"instant": 100
}
数据解释
- slow 慢
- standard 标准
- fast 快速
- instant 即时
“慢”,“标准”,“快速”和“即时”值代表最近200个区块的最低汽油价格。 默认情况下,慢表示30%的概率,标准为60%,快为90%,即时为100%。
常见问题
numpy: Something is wrong with the numpy installation.
python3 gasprice.py
Traceback (most recent call last):
File "gasprice.py", line 4, in <module>
import pandas as pd
File "/home/surou/.local/lib/python3.6/site-packages/pandas/__init__.py", line 17, in <module>
"Unable to import required dependencies:\n" + "\n".join(missing_dependencies)
ImportError: Unable to import required dependencies:
numpy: Something is wrong with the numpy installation. While importing we detected an older version of numpy in ['/home/surou/.local/lib/python3.6/site-packages/numpy']. One method of fixing this is to repeatedly uninstall numpy until none is found, then reinstall this version.
解决方法
rm -rf ~/.local/lib/python3.6/site-packages/numpy
pip install numpy
No module named 'click'
ModuleNotFoundError: No module named 'click'
解决方法
pip3 install click
最新文章
Solana 中的 Tx.origin、msg.sender 和 onlyOwner:识别调用者跨链桥跨链过程中数据变化polygon cdk aggregator 报execution reverted (0x09bde339)polygon cdk Aggregator使用SequencerPrivateKey的时机polygon da 判断DA服务是否正常polygon cdk sequence sender 发送 sequenceBatchesValidium的时机polygon cdk 查看最新提交L1batch numCDK 部署或重置后第一笔交易error: latest Synced BlockNumber (7089137) is higher than the latest Proposed block (1008) in the networkpolygon cdk 跨链桥交易处理流程分析
最新回复
fzd: 请问这个解决了吗
StarkWare explained: layer 2 solution provider of dYdX and iMMUTABLE R11; BitKeep News: [...]Layer 2: https://...
一文读懂 StarkWare:dYdX 和 Immutable 背后的 L2 方案 R11; BitKeep 博客: [...]Layer 2:Comparing Laye...
http://andere.strikingly.com/: Regards, Great stuff!
surou: 需要先执行提案合约申请,等待出块节点地址同意后,才会进...
heco: WARN [11-19|11:26:09.459] N...
P: 你好,我在heco链上遇到了“tx fee excee...
Peng: 楼主安装成功了吗?我正在同步区块链,一天了,差不多才同...
joyhu: 你好,请问下安装好之后如何获取到bee.yaml配置文...
kaka: 支票最终怎么提币呢?
归档
November 2024October 2024September 2024August 2024July 2024June 2024May 2024April 2024March 2024January 2024December 2023November 2023October 2023September 2023August 2023July 2023June 2023April 2023March 2023February 2023January 2023December 2022November 2022October 2022August 2022July 2022June 2022May 2022March 2022February 2022January 2022December 2021November 2021October 2021September 2021August 2021July 2021June 2021May 2021April 2021March 2021February 2021January 2021December 2020November 2020October 2020September 2020July 2020June 2020May 2020April 2020March 2020February 2020January 2020December 2019November 2019October 2019September 2019August 2019July 2019June 2019May 2019April 2019March 2019February 2019January 2019December 2018November 2018October 2018September 2018August 2018July 2018June 2018