I’m surprised that we can make HTTP outcalls from locally deployed canisters. I’m currently grabbing images from an API which should be pretty expensive (size is 400k bytes → 4 cents?) and it seems I could be doing this all day long without paying for it myself? How this is being handled and why is it possible to talk to the management canister of the IC from a local replica anyway?
I can’t confirm, just my guesses from using it for a while, but it may be that when you deploy, you use your local wallet’s cycles, (which you can see with dfx wallet balance
, as opposed to dfx wallet --network ic balance
) and then depending on how many cycles you’re adding per call, it could be a lot less than what mainnet will require. The minimum is something like 610M per call I think.
All of that might (not sure) also get reset whenever you dfx start --clean
or redeploy.
You’re really connecting from your computer, not from the IC, so things to keep in mind include
- they may cost many more cycles on mainnet (possibly around n times more, where n is the number of nodes in the subnet?)
- you’re able to connect to IPv4 locally, which you won’t on mainnet (I’d advice checking with
ping6 google.com
[with the api domain you’re calling instead] to know if it can work on mainnet) - the response is likely not to be identical for every node, so it will fail on mainnet if you don’t transform it, something that will never happen locally because you only call once there.
Thank you! Very valuable hints you’re giving there. I somehow assumed that the call would get routed from my local replica to the IC which would then make the call. I was also wondering why I get different error messages locally than on the IC, but that explains it. Did the math now and the call indeed costs roughly 0.04 USD on the IC.