{"id":23263237,"url":"https://github.com/wavesplatform/waves-rust","last_synced_at":"2025-08-20T18:35:16.206Z","repository":{"id":50656713,"uuid":"519509730","full_name":"wavesplatform/waves-rust","owner":"wavesplatform","description":null,"archived":false,"fork":false,"pushed_at":"2023-12-11T13:53:17.000Z","size":298,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-14T01:00:09.449Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wavesplatform.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-30T12:23:54.000Z","updated_at":"2024-01-16T16:28:50.000Z","dependencies_parsed_at":"2023-01-31T00:21:33.747Z","dependency_job_id":null,"html_url":"https://github.com/wavesplatform/waves-rust","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wavesplatform%2Fwaves-rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wavesplatform%2Fwaves-rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wavesplatform%2Fwaves-rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wavesplatform%2Fwaves-rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wavesplatform","download_url":"https://codeload.github.com/wavesplatform/waves-rust/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230379996,"owners_count":18216847,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-19T14:15:43.636Z","updated_at":"2024-12-19T14:15:44.251Z","avatar_url":"https://github.com/wavesplatform.png","language":"Rust","readme":"# waves-rust\nA Rust library for interacting with the Waves blockchain.\n\nSupports node interaction, offline transaction signing and creating addresses and keys.\n\n## Using waves-rust in your project\nUse the code below to add waves-rust as a dependency for your project.\n\n##### Requirements:\n- edition \"2021\"\n- rust-version \"1.56\" or above\n- tokio runtime to interact with node REST-API\n\n##### Cargo:\n```cargo\n[dependencies]\nwaves-rust = \"0.2.2\"\ntokio = { version = \"1.12.0\", features = [\"full\"] }\n```\n\n### Getting started\nCreate an account from a private key ('T' for testnet) from random seed phrase:\n```rust\nuse waves_rust::model::{ChainId, PrivateKey};\nuse waves_rust::util::Crypto;\n\nlet seed_phrase = Crypto::get_random_seed_phrase(12);\nlet private_key = PrivateKey::from_seed(\u0026seed_phrase, 0).unwrap();\nlet public_key = private_key.public_key();\nlet address = public_key.address(ChainId::TESTNET.byte()).unwrap();\n```\n\nCreate a Node and learn a few things about blockchain:\n```rust\nuse waves_rust::api::{Node, Profile};\nuse waves_rust::model::Address;\n\n#[tokio::main]\nasync fn get_node_info() {\n    let node = Node::from_profile(Profile::TESTNET);\n    println!(\"Current height is {}\", node.get_height().await.unwrap());\n    println!(\"My balance is {}\", node.get_balance(\u0026address).await.unwrap());\n    println!(\"With 100 confirmations: {}\", node.get_balance_with_confirmations(\u0026address, 100).await.unwrap());\n}\n```\n\nSend some money to a buddy:\n```rust\nuse waves_rust::api::{Node, Profile};\nuse waves_rust::model::{Address, Amount, Base58String, ChainId, PrivateKey, Transaction, TransactionData, TransferTransaction};\nuse waves_rust::util::get_current_epoch_millis;\n\nlet buddy = Address::from_string(\"3N2yqTEKArWS3ySs2f6t8fpXdjX6cpPuhG8\").unwrap();\n\nlet transaction_data = TransactionData::Transfer(TransferTransaction::new(\n    buddy,\n    Amount::new(1_00_000_000, None), // None is WAVES asset\n    Base58String::from_string(\"thisisattachment\").unwrap(),\n));\n\nlet timestamp = get_current_epoch_millis();\nlet signed_tx = Transaction::new(\n    transaction_data,\n    Amount::new(100000, None),\n    timestamp,\n    private_key.public_key(),\n    3,\n    ChainId::TESTNET.byte(),\n)\n.sign(\u0026private_key)\n.unwrap();\n\nnode.broadcast(\u0026signed_tx).await.unwrap();\n```\n\nSet a script on an account. Be careful with the script you pass here, as it may lock the account forever!\n```rust\nuse waves_rust::api::{Node, Profile};\nuse waves_rust::model::{Address, Amount, ChainId, PrivateKey, SetScriptTransaction, Transaction, TransactionData};\nuse waves_rust::util::get_current_epoch_millis;\n\nlet script =\n\"{-# CONTENT_TYPE EXPRESSION #-} sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)\";\n\nlet compiled_script = node.compile_script(script, true).await.unwrap();\nlet transaction_data =\nTransactionData::SetScript(SetScriptTransaction::new(compiled_script.script()));\n\nlet timestamp = get_current_epoch_millis();\nlet signed_tx = Transaction::new(\n    transaction_data,\n    Amount::new(100000, None),\n    timestamp,\n    private_key.public_key(),\n    3,\n    ChainId::TESTNET.byte(),\n)\n.sign(\u0026private_key)\n.unwrap();\n\nnode.broadcast(\u0026signed_tx).await.unwrap();\n```\n\n### Reading transaction info\n[Same transaction from REST API](https://nodes-stagenet.wavesnodes.com/transactions/info/CWuFY42te67sLmc5gwt4NxwHmFjVfJdHkKuLyshTwEct)\n\n```rust\nuse waves_rust::api::{Node, Profile};\nuse waves_rust::model::{Address, ByteString, ChainId, Id, TransactionDataInfo};\n\nlet node = Node::from_profile(Profile::STAGENET);\n\nlet id = Id::from_string(\"CWuFY42te67sLmc5gwt4NxwHmFjVfJdHkKuLyshTwEct\").unwrap();\nlet tx_info = node.get_transaction_info(\u0026id).await.unwrap();\n\nprintln!(\"type: {:?}\", tx_info.tx_type());\nprintln!(\"id: {:?}\", tx_info.id());\nprintln!(\"fee: {:?}\", tx_info.fee().value());\nprintln!(\"feeAssetId: {:?}\", tx_info.fee().asset_id());\nprintln!(\"timestamp: {:?}\", tx_info.timestamp());\nprintln!(\"version: {:?}\", tx_info.version());\nprintln!(\"chainId: {:?}\", tx_info.chain_id());\nprintln!(\"sender: {:?}\",tx_info.public_key().address(ChainId::STAGENET.byte()).unwrap().encoded());\nprintln!(\"senderPublicKey: {:?}\", tx_info.public_key().encoded());\nprintln!(\"height: {:?}\", tx_info.height());\nprintln!(\"applicationStatus: {:?}\", tx_info.status());\n\nlet eth_tx = match tx_info.data() {\n    TransactionDataInfo::Ethereum(eth_tx) =\u003e eth_tx,\n    _ =\u003e panic!(\"expected ethereum transaction\"),\n};\n\nprintln!(\"bytes: {}\", eth_tx.bytes().encoded());\nprintln!(\"{:?}\", eth_tx.payload());\n```\n\n### Broadcasting transactions\n#### Creating accounts (see Getting started for more info about account creation)\n```rust\nuse waves_rust::model::PrivateKey;\nuse waves_rust::util::Crypto;\n\nlet bob = PrivateKey::from_seed(\u0026Crypto::get_random_seed_phrase(12), 0).unwrap();\nlet alice = PrivateKey::from_seed(\u0026Crypto::get_random_seed_phrase(12), 0).unwrap();\n```\n#### Broadcasting exchange transaction\n```rust\nuse waves_rust::api::{Node, Profile};\nuse waves_rust::model::{Amount, AssetId, ChainId, ExchangeTransaction, Order, OrderType, PriceMode, PrivateKey, Transaction, TransactionData};\nuse waves_rust::util::{get_current_epoch_millis, Crypto};\n\nlet price = Amount::new(1000, None);\nlet amount = Amount::new(\n    100,\n    Some(AssetId::from_string(\"8bt2MZjuUCJPmfucPfaZPTXqrxmoCHCC8gVnbjZ7bhH6\").unwrap()),\n);\n\nlet matcher_fee = 300000;\n\nlet buy = Order::v4(\n    ChainId::TESTNET.byte(),\n    get_current_epoch_millis(),\n    alice.public_key(),\n    Amount::new(300000, None),\n    OrderType::Buy,\n    amount.clone(),\n    price.clone(),\n    bob.public_key(),\n    Order::default_expiration(get_current_epoch_millis()),\n    PriceMode::AssetDecimals,\n)\n.sign(\u0026alice)\n.unwrap();\n\nlet sell = Order::v3(\n    ChainId::TESTNET.byte(),\n    get_current_epoch_millis(),\n    bob.public_key(),\n    Amount::new(300000, None),\n    OrderType::Sell,\n    amount.clone(),\n    price.clone(),\n    bob.public_key(),\n    Order::default_expiration(get_current_epoch_millis()),\n)\n.sign(\u0026bob)\n.unwrap();\n\nlet transaction_data = TransactionData::Exchange(ExchangeTransaction::new(\n    buy.clone(),\n    sell.clone(),\n    amount.value(),\n    price.value(),\n    matcher_fee,\n    matcher_fee,\n));\n\nlet timestamp = get_current_epoch_millis();\nlet signed_tx = Transaction::new(\n    transaction_data,\n    Amount::new(300000, None),\n    timestamp,\n    bob.public_key(),\n    4,\n    ChainId::TESTNET.byte(),\n)\n.sign(\u0026bob)\n.unwrap();\n\nlet tx_info = node.broadcast(\u0026signed_tx).await.unwrap();\n```\n\n### Working with dApp\n#### Creating accounts (see Getting started for more info about account creation)\n```rust\nuse waves_rust::model::PrivateKey;\nuse waves_rust::util::Crypto;\n\nlet bob = PrivateKey::from_seed(\u0026Crypto::get_random_seed_phrase(12), 0);\nlet alice = PrivateKey::from_seed(\u0026Crypto::get_random_seed_phrase(12), 0);\n```\n#### Broadcasting issue transaction\n```rust\nuse waves_rust::api::{Node, Profile};\nuse waves_rust::model::{Amount, ChainId, IssueTransaction, PrivateKey, Transaction, TransactionData};\nuse waves_rust::util::{Crypto, get_current_epoch_millis};\n\nlet transaction_data = TransactionData::Issue(IssueTransaction::new(\n        \"Asset\".to_owned(),\n        \"this is test asset\".to_owned(),\n        1000,\n        2,\n        false,\n        None,\n));\n\nlet timestamp = get_current_epoch_millis();\nlet signed_tx = Transaction::new(\n    transaction_data,\n    Amount::new(100400000, None),\n    timestamp,\n    alice.public_key(),\n    3,\n    ChainId::TESTNET.byte(),\n)\n.sign(\u0026alice)\n.unwrap();\n\nnode.broadcast(\u0026signed_tx).await.unwrap();\n```\n\n#### Compiling and broadcasting RIDE script\n```rust\nuse waves_rust::api::{Node, Profile};\nuse waves_rust::model::{Amount, ChainId, PrivateKey, SetScriptTransaction, Transaction, TransactionData};\nuse waves_rust::util::{get_current_epoch_millis, Crypto};\n\nlet script = r#\"\n        {-# STDLIB_VERSION 5 #-}\n        {-# CONTENT_TYPE DAPP #-}\n        {-# SCRIPT_TYPE ACCOUNT #-}\n        \n        @Callable(inv)\n        func call(bv: ByteVector, b: Boolean, int: Int, str: String, list: List[Int]) = {\n             let asset = Issue(\"Asset\", \"\", 1, 0, true)\n             let assetId = asset.calculateAssetId()\n             let lease = Lease(inv.caller, 7)\n             let leaseId = lease.calculateLeaseId()\n             [\n                BinaryEntry(\"bin\", assetId),\n                BooleanEntry(\"bool\", true),\n                IntegerEntry(\"int\", 100500),\n                StringEntry(\"assetId\", assetId.toBase58String()),\n                StringEntry(\"leaseId\", leaseId.toBase58String()),\n                StringEntry(\"del\", \"\"),\n                DeleteEntry(\"del\"),\n                asset,\n                SponsorFee(assetId, 1),\n                Reissue(assetId, 4, false),\n                Burn(assetId, 3),\n                ScriptTransfer(inv.caller, 2, assetId),\n                lease,\n                LeaseCancel(lease.calculateLeaseId())\n             ]\n        }\n\"#;\n\nlet compiled_script = node.compile_script(script, true).await.unwrap();\n\nlet transaction_data = TransactionData::SetScript(SetScriptTransaction::new(compiled_script.script()));\n\nlet timestamp = get_current_epoch_millis();\nlet signed_tx = Transaction::new(\n    transaction_data,\n    Amount::new(500000, None),\n    timestamp,\n    alice.public_key(),\n    3,\n    ChainId::TESTNET.byte(),\n)\n.sign(\u0026alice)\n.unwrap();\n\nnode.broadcast(\u0026signed_tx).await.unwrap();\n```\n\n#### Calling dApp\n```rust\nuse waves_rust::api::{Node, Profile};\nuse waves_rust::model::{Address, Amount, Base64String, ByteString, ChainId, Function, InvokeScriptTransaction, PrivateKey, Transaction, TransactionData};\nuse waves_rust::model::Arg::{Binary, Boolean, Integer, List, String};\nuse waves_rust::util::{get_current_epoch_millis, Crypto};\n\nlet alice_address =\nAddress::from_public_key(ChainId::TESTNET.byte(), \u0026alice.public_key()).unwrap();\nlet transaction_data = TransactionData::InvokeScript(InvokeScriptTransaction::new(\n    alice_address.clone(),\n    Function::new(\n        \"call\".to_owned(),\n        vec![\n            Binary(Base64String::from_bytes(vec![1, 2, 3])),\n            Boolean(true),\n            Integer(100500),\n            String(alice_address.encoded()),\n            List(vec![Integer(100500)]),\n        ],\n    ),\n    vec![\n        Amount::new(1, None),\n        Amount::new(2, None),\n        Amount::new(3, None),\n        Amount::new(4, None),\n    ],\n));\n\nlet timestamp = get_current_epoch_millis();\nlet signed_tx = Transaction::new(\n    transaction_data,\n    Amount::new(100500000, None),\n    timestamp,\n    bob.public_key(),\n    3,\n    ChainId::TESTNET.byte(),\n)\n.sign(\u0026bob)\n.unwrap();\n\nnode.broadcast(\u0026signed_tx).await.unwrap();\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwavesplatform%2Fwaves-rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwavesplatform%2Fwaves-rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwavesplatform%2Fwaves-rust/lists"}