-
Notifications
You must be signed in to change notification settings - Fork 4
Solidity smart contract
zTgx edited this page Aug 2, 2019
·
1 revision
extern crate jlib;
use jlib::misc::config::*;
use jlib::{SolidityDeploy, SolidityInitResponse};
fn main() {
let config = Config::new(TEST1, true);
let account = "jHb9CJAWyB4jr91VRWn96DkukG4bwdtyTh".to_string();
let secret = "snoPBjXtMeMyMHUVTgbuqAfg1SUTb".to_string();
let payload = "608060405234801561001057600080fd5b5060a48061001f6000396000f3fe6080604052348015600f57600080fd5b50600436106044577c0100000000000000000000000000000000000000000000000000000000600035046384e9ec3f81146049575b600080fd5b606360048036036020811015605d57600080fd5b50356075565b60408051918252519081900360200190f35b9056fea165627a7a7230582085890b2dceadbce6c6e9939a89026c2cc9b81b899445d5109cba8087166134a20029".to_string();
SolidityDeploy::with_params(config, &account, &secret).deploy(&payload, |x| match x {
Ok(response) => {
let res: SolidityInitResponse = response;
println!("deploy contract : {:?}", &res);
},
Err(err) => {
println!("err: {:?}", err);
}
});
}
extern crate jlib;
use jlib::misc::config::*;
use jlib::{SolidityCall, SolidityInvokeResponse};
use jlib::Arg;
fn main() {
let config = Config::new(TEST1, 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);
// 不带参数的调用
// let message = SolidityInvokeMessage::with_params(account, secret, address, "6236653435366262".to_string(), v);
// 带参数的调用
// let p = Arg::new("79".to_string(), 0);
// v.push(p);
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);
}
});
}