use heliosphere::RpcClient; use heliosphere_signer::keypair::Keypair; #[tokio::test] async fn deploy_contract() { let api = "https://api.shasta.trongrid.io"; let keypair = Keypair::from_hex_key( std::fs::read_to_string(".key") .expect("no ./.key found") .trim(), ) .unwrap(); let client = RpcClient::new(api).unwrap(); let abi = "[{\"constant\":false,\"inputs\":[{\"name\":\"key\",\"type\":\"uint256\"},{\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"set\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"key\",\"type\":\"uint256\"}],\"name\":\"get\",\"outputs\":[{\"name\":\"value\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}]"; let bytecode = hex::decode("608060405234801561001057600080fd5b5060de8061001f6000396000f30060806040526004361060485763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416631ab06ee58114604d5780639507d39a146067575b600080fd5b348015605857600080fd5b506065600435602435608e565b005b348015607257600080fd5b50607c60043560a0565b60408051918252519081900360200190f35b60009182526020829052604090912055565b600090815260208190526040902054905600a165627a7a72305820fdfe832221d60dd582b4526afa20518b98c2e1cb0054653053a844cf265b25040029").unwrap(); let name = "SmartContract"; let ca = client .deploy_contract(abi, &bytecode, name, &keypair, 1000000000, 500000, 0) .await .unwrap(); println!("CA: {}", ca); }