MCPcopy Create free account
hub / github.com/ddimaria/rust-blockchain-tutorial / load_contract

Function load_contract

runtime/src/contract.rs:24–41  ·  view source on GitHub ↗
(bytes: &[u8])

Source from the content-addressed store, hash-verified

22}
23
24fn load_contract(bytes: &[u8]) -> Result<(Store<i32>, Instance)> {
25 let mut config = Config::new();
26
27 Config::wasm_component_model(&mut config, true);
28
29 let engine = Engine::new(&config)?;
30 let mut store = Store::new(&engine, 0);
31 let linker = Linker::new(&engine);
32
33 let component_bytes = ComponentEncoder::default()
34 .module(bytes)?
35 .validate(true)
36 .encode()?;
37 let component = Component::from_binary(&engine, &component_bytes)?;
38 let instance = linker.instantiate(&mut store, &component)?;
39
40 Ok((store, instance))
41}
42
43// TODO(ddimaria): remove unwrap
44fn parse_params(chunk: &[&str]) -> Result<Val> {

Callers 2

call_functionFunction · 0.85
it_loads_a_contractFunction · 0.85

Calls

no outgoing calls

Tested by 1

it_loads_a_contractFunction · 0.68