Struct multiversx_sdk::data::address::Address
source · pub struct Address(_);Implementations§
source§impl Address
impl Address
pub fn from_bytes(bytes: [u8; 32]) -> Self
pub fn to_bytes(&self) -> [u8; 32]
sourcepub fn from_bech32_string(bech32: &str) -> Result<Self>
pub fn from_bech32_string(bech32: &str) -> Result<Self>
Examples found in repository?
More examples
examples/tx_default_args.rs (lines 10-12)
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
async fn main() {
let blockchain = CommunicationProxy::new(DEVNET_GATEWAY.to_string());
let network_config = blockchain.get_network_config().await.unwrap();
let addr = Address::from_bech32_string(
"erd1qqqqqqqqqqqqqpgqfzydqmdw7m2vazsp6u5p95yxz76t2p9rd8ss0zp9ts",
)
.unwrap();
let arg = blockchain
.get_default_transaction_arguments(&addr, &network_config)
.await
.unwrap();
println!("default tx arg: {arg:#?}");
}examples/vm_query.rs (lines 16-18)
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
async fn main() {
let wl = Wallet::from_private_key(
"1648ad209d6b157a289884933e3bb30f161ec7113221ec16f87c3578b05830b0",
)
.unwrap();
let addr = wl.address();
let blockchain = CommunicationProxy::new(DEVNET_GATEWAY.to_string());
let req = VmValueRequest {
sc_address: Address::from_bech32_string(
"erd1qqqqqqqqqqqqqpgqhn3ae8dpc957t7jadn7kywtg503dy7pnj9ts3umqxx",
)
.unwrap(),
func_name: "get".to_string(),
args: vec![],
caller: addr.clone(),
value: "0".to_string(),
};
let result = blockchain.execute_vmquery(&req).await;
println!("{result:#?}");
}examples/tx_cost.rs (lines 11-13)
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
async fn main() {
let tx = Transaction {
nonce: 1,
value: "50".to_string(),
receiver: Address::from_bech32_string(
"erd1rh5ws22jxm9pe7dtvhfy6j3uttuupkepferdwtmslms5fydtrh5sx3xr8r",
)
.unwrap(),
sender: Address::from_bech32_string(
"erd1rh5ws22jxm9pe7dtvhfy6j3uttuupkepferdwtmslms5fydtrh5sx3xr8r",
)
.unwrap(),
data: Some(base64::encode("hello")),
chain_id: "1".to_string(),
version: 1,
options: 0,
gas_limit: 0,
gas_price: 0,
signature: None,
};
let blockchain = CommunicationProxy::new(DEVNET_GATEWAY.to_string());
let cost = blockchain.request_transaction_cost(&tx).await.unwrap();
println!("tx cost: {cost:#?}");
assert_eq!(
cost.tx_gas_units, 57500,
"receive cost {}",
cost.tx_gas_units
);
}pub fn to_bech32_string(&self) -> Result<String>
pub fn is_valid(&self) -> bool
Trait Implementations§
source§impl<'de> Deserialize<'de> for Address
impl<'de> Deserialize<'de> for Address
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl RefUnwindSafe for Address
impl Send for Address
impl Sync for Address
impl Unpin for Address
impl UnwindSafe for Address
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more