#key #elrond #transaction #generate-keys #account #address #load

elrond-rust

用于在Elrond网络上生成密钥和创建和签名交易的库

1个不稳定版本

0.1.0 2020年9月21日

#17 in #elrond

MIT 许可证

25KB
451

elrond-rust

在Elrond网络上生成密钥、创建和签名交易。此库及其依赖项均用纯Rust编写,以允许将来轻松生成WASM。请参阅测试以获取更多示例。

免责声明:此代码未经过正确性审计,使用风险自担。

示例交互

use elrond_rust::client::Client;
use elrond_rust::account::{Account, ElrondAddress};
use elrond_rust::transaction::{UnsignedTransaction, Network};

// initialize new client
let client = Client::new();
// load account from private/secret key
let private_key = "a4b36a5d97176618b5a7fcc9228d2fd98ee2f14ddd3d6462ae03e40eb487d15b";
let account = Account::from_string(private_key).unwrap();
// look up the current account nonce to use for the tx
let nonce = client.get_address_nonce(&account.address).unwrap();
// create a new transaction to send 1 eGLD to some address
let tx = UnsignedTransaction::new(
    nonce, // current nonce
    "1", // amount of eGLD
    "erd16jats393r8rnut88yhvu5wvxxje57qzlj3tqk7n6jnf7f6cxs4uqfeh65k", // reciever
    &account.address.to_string(), // the account
    Network::MainNet
).unwrap();
// sign the transaction
let signed_tx = tx.sign(&account).unwrap();
// submit the transaction to the network
client.post_signed_transaction(signed_tx).unwrap();

密钥生成

use elrond_rust::account::Account;
let account = Account::generate();
// access key representations provided by ed25519_dalek 
let secret = account.secret;
let public = account.public;

依赖项

~7MB
~170K SLoC