Smart contracts
A programming language for the code that holds money.
Inference is a programming language for smart contracts and other financial logic that has to be exact. Amounts are integers, overflow stops the program instead of wrapping, and there is no floating point. You write the contract and the rules it must keep, and the rules are checked against every possible input.
Install
curl -fsSL https://inference-lang.org/install.sh | shVS Code extension, tree-sitter grammar, published language specification and book.
// A transfer is allowed only when the amount is positive,
// within the daily limit, and covered by the balance.
pub fn transfer_allowed(
balance: i32, amount: i32, daily_limit: i32
) -> bool {
return amount >= 1
&& amount <= daily_limit
&& amount <= balance;
}
spec TransferSafety {
// forall: the rule must hold on every path.
fn never_overdraws() forall {
// @ stands for every value of its type.
let balance: i32 = @;
let amount: i32 = @;
let daily_limit: i32 = @;
assume {
assert(balance >= 0);
assert(amount >= 1 && balance < amount);
}
// More than the balance never leaves the account.
assert(!transfer_allowed(balance, amount, daily_limit));
}
}Designed for
These are the uses Inference is designed for, not a list of customers.
Smart contracts on Stellar
From v0.0.6, an Inference program builds into a contract you can deploy on Soroban, Stellar's smart contract platform.
DeFi protocol logic
State machines and limit checks on code that is public once deployed and holds other people's funds.
Financial and banking systems
Balances, limits and authorisation rules, where an off-by-one is somebody's money.
In scope, out of scope
We would rather lose an evaluation early than be discovered late. Here is the boundary.
In scope
- State machines
- Command validation and authorisation
- Limit checks
All of the above over integers and booleans.
Out of scope
- Floating-point arithmetic
- Machine-learning models
Code outside the boundary stays in the language it is written in. Inference checks the rules around it.
Why a coding agent can reason about it
Inference is strict and structurally simple on purpose. There is no garbage collector and no heap allocator. Arrays and structs are fixed-size, laid out in WebAssembly linear memory. Integer overflow stops the program unless you explicitly ask for wrapping. There is very little implicit behaviour for a reader to infer, which is the same property that makes a program tractable for a human reviewer and for a model generating code against a set of rules. When a rule does not hold, the diagnostic names the rule.
Checked for every input, not a sample
A test tells you a rule held for the inputs someone tried. Inference checks the rule for all of them. What you keep at the end is not a report that someone looked at the code: it is a check your own engineers can re-run whenever the contract changes.
Building a contract in Inference?
Tell us what the contract holds and which rules it must never break. An engineer who works on the language reads every message and replies.