Contains utilities for encoding smart contract calls to SCALE.
Currently part of cargo-contract
, the build tool for smart
contracts written in ink!.
```rust use transcode::ContractMessageTranscoder;
fn main() { let metadata_path = "/path/to/metadata.json";
let metadata = load_metadata(&metadata_path.into())?;
let transcoder = ContractMessageTranscoder::new(&metadata);
let constructor = "new";
let args = ["foo", "bar"];
let data = transcoder.encode(&constructor, &args).unwrap();
println!("Encoded constructor data {:?}", data);
}
fn loadmetadata(path: &Path) -> anyhow::Result
if let ink_metadata::MetadataVersioned::V3(ink_project) = ink_metadata {
Ok(ink_project)
} else {
Err(anyhow!("Unsupported ink metadata version. Expected V3"))
}
}
```