3 个不稳定版本
0.3.0 | 2023年12月5日 |
---|---|
0.2.1 |
|
0.2.0 |
|
0.1.1 | 2020年11月10日 |
0.1.0 | 2020年11月10日 |
#5 in #gem
在 gemgen 中使用
66KB
1.5K SLoC
gem-lib-rust
用于与 Gem 区块链交互的库
用法
use std::time::{SystemTime, UNIX_EPOCH};
use gemblockchain::account::{PrivateKeyAccount, TESTNET};
use gemblockchain::base58::*;
use gemblockchain::seed::*;
use gemblockchain::transaction::*;
fn main() {
let phrase = generate_phrase();
let account = PrivateKeyAccount::from_seed(&phrase);
println!("My TESTNET address: {}", account.public_key().to_address(TESTNET).to_string());
let ts = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs() * 1000;
let tx = Transaction::new_alias(&account.public_key(), "rhino", TESTNET, 100000, ts);
println!("ID is {}", tx.id().to_string());
let ptx = account.sign_transaction(tx);
println!("Proofs are {:?}", ptx.proofs.iter().map(|p| p.to_base58()).collect::<Vec<String>>());
}
lib.rs
:
gemblockchain
与 Gem 区块链交互的库。
支持离线交易签名、创建地址和密钥。
用法
use std::time::{SystemTime, UNIX_EPOCH};
use gemblockchain::account::{PrivateKeyAccount, TESTNET};
use gemblockchain::base58::*;
use gemblockchain::seed::*;
use gemblockchain::transaction::*;
fn main() {
let phrase = generate_phrase();
let account = PrivateKeyAccount::from_seed(&phrase);
println!(
"My TESTNET address: {}",
account.public_key().to_address(TESTNET).to_string()
);
let ts = SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs()
* 1000;
let tx = Transaction::new_alias(&account.public_key(), "rhino", TESTNET, 100000, ts);
println!("ID is {}", tx.id().to_string());
let ptx = account.sign_transaction(tx);
println!(
"Proofs are {:?}",
ptx.proofs
.iter()
.map(|p| p.to_base58())
.collect::<Vec<String>>()
);
}
依赖项
~11–26MB
~401K SLoC