18 个版本
新版本 0.4.7 | 2024 年 8 月 21 日 |
---|---|
0.4.1 | 2024 年 2 月 26 日 |
0.3.25 | 2024 年 2 月 16 日 |
0.3.17 | 2023 年 12 月 6 日 |
0.2.0 | 2023 年 9 月 29 日 |
#20 in 神奇豆子
878 每月下载量
550KB
6K SLoC
rust_erc20_payment
备注
- 数据库中所有地址/事务都采用十六进制/小写格式。
前端
前端仓库链接:https://github.com/scx1332/erc20_driver_frontend
示例环境设置
ETH_PRIVATE_KEY=0000000000000000000000000000000000000000000000000000000000000000 PROVIDER_URL=https://rpc-mumbai.matic.today RUST_LOG=debug,sqlx::query=info,web=warn
示例运行
cargo run -- transfer --plain-eth --amounts=1,2,3,4 --receivers=0xA000000000000000000000000000000000050001,0xA000000000000000000000000000000000050002,0xa000000000000000000000000000000000050003,0xa000000000000000000000000000000000050004
cargo run -- transfer --token-addr=0x2036807b0b3aaf5b1858ee822d0e111fddac7018 --amounts=1,2,3,4 --receivers=0xA000000000000000000000000000000000050001,0xA000000000000000000000000000000000050002,0xa000000000000000000000000000000000050003,0xa000000000000000000000000000000000050004
cargo run --example generate_transfers -- --chain-name dev --address-pool-size 10000 --amounts-pool-size 10000 --generate-count 100
准备测试转账到数据库,它生成 100 条随机 GLM 转账到 10 个唯一地址
cargo运行 --示例generate_transfers ----generate-count 100 --address-pool-size 10 --amounts-pool-size=100
模拟运行,不处理事务
cargo运行 --process --generate-tx-only=1
查看正在处理的事务的有用命令
SELECT id,
(CAST((julianday(broadcast_date) - 2440587.5)*86400000 AS INTEGER) - CAST((julianday(created_date) - 2440587.5)*86400000 AS INTEGER)) / 1000.0 as broadcast_delay,
broadcast_count,
(CAST((julianday(confirm_date) - 2440587.5)*86400000 AS INTEGER) - CAST((julianday(broadcast_date) - 2440587.5)*86400000 AS INTEGER)) / 1000.0 as confirm_delay,
tx_hash,
*
FROM tx
order by created_date desc
清理所有事务和转账
DELETE FROM token_transfer;
DELETE FROM tx;
待办事项
- 在 gather_transactions 中添加错误处理,现在 SQL 会无限循环,当在 gather 中遇到错误时
示例获取余额
并行运行 4 个任务获取余额
cargo run -- account-balance --tasks 4 -c polygon -a 0x75be52afd54a13b6c98490b4db495aa79b609d58,0x7caac644722316101807e0d55f838f7851a97031,0x52a258ed593c793251a89bfd36cae158ee9fc4f8,0x04e2dc96afecdf72221882e1cee039cab4d443e0,0xa32a0edc623d86e623f58e7c4174023a80a67ddf,0x7cb53b925a79fb15c348fcfd9abcf2287854d33a,0x8cf88c473b6cb40b8d37cdd93e6c8118c14a6e60,0xa96d3f3e177687fb0b5f990d5c4000923b49430b,0x92fb36230b50a87a39ba3237c996caf5a39b230b,0x0c4d7a995aa9846ef25e1a347a8711c8b534b5a6,0x698076ae39e7e44bcd2bbe15f0486c8d44bb4e6f
逐一处理端点会更友好
cargo run -- account-balance --tasks 1 -c polygon -a 0x75be52afd54a13b6c98490b4db495aa79b609d58,0x7caac644722316101807e0d55f838f7851a97031,0x52a258ed593c793251a89bfd36cae158ee9fc4f8,0x04e2dc96afecdf72221882e1cee039cab4d443e0,0xa32a0edc623d86e623f58e7c4174023a80a67ddf,0x7cb53b925a79fb15c348fcfd9abcf2287854d33a,0x8cf88c473b6cb40b8d37cdd93e6c8118c14a6e60,0xa96d3f3e177687fb0b5f990d5c4000923b49430b,0x92fb36230b50a87a39ba3237c996caf5a39b230b,0x0c4d7a995aa9846ef25e1a347a8711c8b534b5a6,0x698076ae39e7e44bcd2bbe15f0486c8d44bb4e6f
每 2 秒处理一次端点速率限制会更友好
cargo run -- account-balance --interval 2.0 -c polygon -a 0x75be52afd54a13b6c98490b4db495aa79b609d58,0x7caac644722316101807e0d55f838f7851a97031,0x52a258ed593c793251a89bfd36cae158ee9fc4f8,0x04e2dc96afecdf72221882e1cee039cab4d443e0,0xa32a0edc623d86e623f58e7c4174023a80a67ddf,0x7cb53b925a79fb15c348fcfd9abcf2287854d33a,0x8cf88c473b6cb40b8d37cdd93e6c8118c14a6e60,0xa96d3f3e177687fb0b5f990d5c4000923b49430b,0x92fb36230b50a87a39ba3237c996caf5a39b230b,0x0c4d7a995aa9846ef25e1a347a8711c8b534b5a6,0x698076ae39e7e44bcd2bbe15f0486c8d44bb4e6f
示例证明
http://deposit.dev.golem.network:15555/erc20/api/attestation/sepolia/0xeb9b088871155d0ae32f382de5a42d0a64e946f512b722698f4ae6b32164f92d http://deposit.dev.golem.network:15555/erc20/api/attestation/sepolia/0xc8b0ceee393cdcf313945d20b3bd45a01b0ccf2484309b669da2d4da9266b4d5 http://deposit.dev.golem.network:15555/erc20/api/attestation/base/0xc0f18976a498f7287562492cca4a145108e83e3606e020f10653afd3511656ef
依赖项
~85MB
~1.5M SLoC