What is an HTTPS Outcall?

HTTPS outcalls allow canister smart contracts hosted on the Internet Computer to request a URL. Canister smart contracts can make HTTPS outcalls to specified URLs to directly obtain off-chain data, or to interact with off-chain systems, such as Web 2.0 services or enterprise IT infrastructure.

An HTTPS outcall mechanism for smart contracts enables a wide range of applications — for example, oracle services directly integrated into the Internet Computer in a trustless manner, user notifications, and anything else that requires communication with servers on the internet.

 

How It Works

When a node requests an outcall, every node in the subnet makes a given HTTP request to the target server and receives a response. Each node then locally passes the result they obtained to a special function implemented by the requesting canister smart contract using a query call, which pre-processes the result with the aim of making it consistent with the results the other nodes have obtained and pre-processed. 

Once the replicas are able to reach consensus on what the response to the request was, they include it as a special type of payload in an IC block. Once this block is finalized, it is passed on to the execution layer, which will deliver the HTTP response. If the pre-processed results obtained by query calls to the canister smart contract are sufficiently consistent across all the nodes, the result is agreed by consensus, and provided back to the smart contract that requested the URL so that it can continue trustlessly processing the original smart contract call. The canister can now safely use the HTTP response to change its state, without risking divergence across replicas.

 

To demonstrate this feature in action, we built an exchange-rate sample dapp, the canister of which makes direct HTTP calls to an off-chain service directly from the Internet Computer. This sample dapp pulls the ICP-to-USDC exchange rate from a Coinbase API directly, without middleman infrastructure — which is just one example of a vast array of data sources that can be called using this feature. For more information on this dapp, you can check out the document here.

 

 

Updated