Expand description
§NEAR Intents smart contracts
§What is NEAR Intents?
NEAR Intents is a smart contract developed for the NEAR blockchain. It facilitates atomic P2P transactions among peers, by allow trustless transactions in the smart contract.
Please note that the main smart contract in the repository, under the directory defuse
, is referred to as the “Verifier” in the ecosystem. Near Intents contains more components that work in tandem to achieve its purpose. Nevertheless, this smart contract, the Verifier, can be used independently without needing anything else.
§Example
Alice wants to trade 1000 USDT with Bob for 1000 USDC. If Alice sends her 1000 USDT first, she risks Bob not fulfilling the promise of sending his 1000 USDC. Same risk for Bob if he goes first.
Solution:
Both Alice and Bob create accounts in the NEAR Intents smart contract. They then deposit their 1000 USDT/USDC. They create two intents. In Alice’s, Alice declares her will to lose 1000 USDT for 1000 USDC, and Bob creates another intent showing his will to lose 1000 USDC for 1000 USDT. Each of them sign their intent. They put both intents in an array, and then call the function execute_intents
in the NEAR Intents smart contract with the intents’ array.
The Verifier smart contract will evaluate the intents and check whether the requests can be fulfilled, and will ensure that the transaction is done atomically, and the 1000 USDC/USDT will be swapped.
Finally, Alice and Bob can withdraw their USDC/USDT from the Verifier smart contract to their individual accounts.
§Documentation
For more information on how to use the Intents ecosystem, please refer to the documentation.
For technical information about the Verifier smart contract programming primitives (and other smart contracts here), please refer to the cargo documentation page.
§The name “defuse”
The name defuse is an old name for the smart contract that we use to execute intents. It is being phased out for NEAR Intents.
§Building and running
You can obtain a working copy of the smart contract and the ABI from the releases page.
Alternatively, you can build this smart contract yourself.
Build the smart contracts:
cargo make build
Run integration tests:
cargo make test
Run clippy linter:
cargo make clippy
After building, the artifacts of the build will be in the res
directory.
§Contracts in this repository
- Verifier/Defuse smart contract: The primary contract for NEAR Intents discussed in this readme file.
PoA Token
andPoA factory
contract: Contracts responsible for the Proof of Authority bridge. These help in transferring tokens from other assets (e.g., Bitcoin, Ethereum, Solana, etc) to the NEAR blockchain, so that transactions in the NEAR Intents can happen.- Controller interface: Interface for contract responsible for upgrading smart contracts and migrating their state.
Re-exports§
pub use defuse_core as core;
pub use defuse_nep245 as nep245;