Here is my code
let final_tx = format!("{}{}","0x",tx_sign);
let rpc_request = RpcRequest{
id:"1".into(),
jsonrpc:"2.0".into(),
method:"eth_gasPrice".into(),
params:vec![]
};
let json_rpc = serde_json::to_vec(
&rpc_request
).map_err(|e| format!("hex::decode failed: {}", e))?;
let request = CanisterHttpRequestArgument{
url:"https://goerli.infura.io/v3/blabla".to_string(),
max_response_bytes: Some(400000),
method:HttpMethod::POST,
headers:vec![
HttpHeader{
name:"Content-Type".to_string(),
value:"application/json".to_string()
}
],
body: Some(
json_rpc
),
transform:Some(TransformContext::new(transform, vec![]))
};
match http_request(request).await {
Ok((result,))=>{
Ok(SignOutput{
tx_sign:format!("{:?}",result.body)
})
}
Err((r, m)) => {
let message =
format!("The http_request resulted into error. RejectionCode: {r:?}, Error: {m}");
Err(message)
}
}
and here is my transformer
#[query]
fn transform(raw: TransformArgs) -> HttpResponse {
let mut res = HttpResponse {
status: raw.response.status.clone(),
..Default::default()
};
if res.status == 200 {
res.body = raw.response.body;
} else {
ic_cdk::api::print(format!("Received an error from jsonropc: err = {:?}", raw));
}
res
}
The full error is looking like this
The http_request resulted into error. RejectionCode: SysTransient, Error: Failed to connect: error trying to connect: tcp connect error: deadline has elapsed