1
2
3
4
5
6
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
extern crate jlib;
use jlib::api::contracts::solidity::{SolidityCall, SolidityInvokeResponse};
use jlib::api::contracts::message::Arg;
use jlib::Config;
pub static TEST_SERVER: &'static str = "ws://42.81.160.87:5020";
fn main() {
let config = Config::new(TEST_SERVER, true);
//invoke
let secret = "snoPBjXtMeMyMHUVTgbuqAfg1SUTb".to_string();
let account = "jHb9CJAWyB4jr91VRWn96DkukG4bwdtyTh".to_string();
let address = "jJpU95p4ekWaJJZ7biS7oSM1QGsetxb269".to_string();
let method_name = "0x84e9ec3f".to_string();
//concat args:
//THe First MUST BE: function name which is to be called.
let mut v: Vec<Arg> = vec![];
let p = Arg::new("3739".to_string(), 0);
v.push(p);
// no params
// let message = SolidityInvokeMessage::with_params(account, secret, address, "6236653435366262".to_string(), v);
// with params
// let p = Arg::new("79".to_string(), 0);
// v.push(p);
// let message = SolidityInvokeMessage::with_params(account, secret, address, "0x84e9ec3f".to_string(), v);
//
// let mut solidity = Solidity::with_config(config);
// solidity.set_invoke_message(message);
// solidity.invoke(|x| match x {
// Ok(response) => {
// let res: SolidityInvokeResponse = response;
// println!("contract info : {:?}", &res);
// },
//
// Err(err) => {
// println!("err: {:?}", err);
// }
// });
SolidityCall::with_params(config, &account, &secret, &address).call(&method_name, v, |x| match x {
Ok(response) => {
let res: SolidityInvokeResponse = response;
println!("call contract : {:?}", &res);
},
Err(err) => {
println!("err: {:?}", err);
}
});
}