cryptocurrency-exchange-script icon indicating copy to clipboard operation
cryptocurrency-exchange-script copied to clipboard

Chainalysis oracle for sanctions screening

Open REDDNoC opened this issue 2 months ago • 0 comments

The Chainalysis oracle is a smart contract that validates if a cryptocurrency wallet address has been included in a sanctions designation. The smart contract is maintained by Chainalysis on a variety of popular blockchains and will be regularly updated to reflect the latest sanctions designations listed on economic/trade embargo lists from organizations including the US, EU, or UN. The smart contract is available for anyone to use and does not require a customer relationship with Chainalysis

Defining Sanctions Data Sanctioned entities refer to entities listed on economic/trade embargo lists, such as by the US, EU, or UN, with which anyone subject to those jurisdictions is prohibited from dealing. Currently, this includes the Specially Designated Nationals (SDN) list of the US Department of the Treasury’s Office of Foreign Assets Control (OFAC). While we will be taking reasonable measures to keep the sanctions oracle up-to-date, Chainalysis cannot guarantee the accuracy, timeliness, suitability, or validity of the data.

Using the Chainalysis oracle You can use the Chainalysis oracle in conjunction with many programming languages. Below we provide an example for Solidity and for Javascript using the popular web3.js library.

Solidity The following code checks whether the address funds are being sent to is on the sanctions list:

pragma solidity ^0.8.12;

interface SanctionsList { function isSanctioned(address addr) external view returns (bool); }

contract ConsumerContract { address constant SANCTIONS_CONTRACT = 0x40C57923924B5c5c5455c48D93317139ADDaC8fb;

function transfer(address to, uint256 amount) external {
    SanctionsList sanctionsList = SanctionsList(SANCTIONS_CONTRACT);
    bool isToSanctioned = sanctionsList.isSanctioned(to);
    require(!isToSanctioned, "Transfer to sanctioned address");
}

}

Javascript The following code checks if an address is on a sanctions list from the web3.js collection of libraries:

const Web3 = require('web3') const rpcurl = "" const web3 = new Web3(rpcurl) const abi = [/* See our ABI below */] const contract_address = "0x40c57923924b5c5c5455c48d93317139addac8fb" contract = new web3.eth.Contract(abi, contract_address) contract.methods.isSanctioned("0x7f268357A8c2552623316e2562D90e642bB538E5").call((err, result) => { console.log("Non-sanctioned address: "); console.log(result); }); contract.methods.isSanctioned("0x7F367cC41522cE07553e823bf3be79A889DEbe1B").call((err, result) => { console.log("Sanctioned address: "); console.log(result); });

This will print:

Non-sanctioned address: false Sanctioned address: true

Compatible networks Currently, the Chainalysis oracle is available on the Ethereum network as well as the following EVM-compatible networks (click the links to view the Chainalysis oracle on each network):

Ethereum: 0x40C57923924B5c5c5455c48D93317139ADDaC8fb Polygon: 0x40C57923924B5c5c5455c48D93317139ADDaC8fb BNB Smart Chain: 0x40C57923924B5c5c5455c48D93317139ADDaC8fb Avalanche: 0x40C57923924B5c5c5455c48D93317139ADDaC8fb Optimism: 0x40C57923924B5c5c5455c48D93317139ADDaC8fb Arbitrum: 0x40C57923924B5c5c5455c48D93317139ADDaC8fb Fantom: 0x40c57923924b5c5c5455c48d93317139addac8fb Celo: 0x40C57923924B5c5c5455c48D93317139ADDaC8fb Blast: 0x40C57923924B5c5c5455c48D93317139ADDaC8fb Base: 0x3A91A31cB3dC49b4db9Ce721F50a9D076c8D739B

Getting help Contact [email protected] to provide feedback or ask us any questions.

ABI [ { "inputs": [], "stateMutability": "nonpayable", "type": "constructor" }, { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "address", "name": "addr", "type": "address" } ], "name": "NonSanctionedAddress", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "address", "name": "previousOwner", "type": "address" }, { "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" } ], "name": "OwnershipTransferred", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "address", "name": "addr", "type": "address" } ], "name": "SanctionedAddress", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "internalType": "address[]", "name": "addrs", "type": "address[]" } ], "name": "SanctionedAddressesAdded", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "internalType": "address[]", "name": "addrs", "type": "address[]" } ], "name": "SanctionedAddressesRemoved", "type": "event" }, { "inputs": [ { "internalType": "address[]", "name": "newSanctions", "type": "address[]" } ], "name": "addToSanctionsList", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "addr", "type": "address" } ], "name": "isSanctioned", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "addr", "type": "address" } ], "name": "isSanctionedVerbose", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "name", "outputs": [ { "internalType": "string", "name": "", "type": "string" } ], "stateMutability": "pure", "type": "function" }, { "inputs": [], "name": "owner", "outputs": [ { "internalType": "address", "name": "", "type": "address" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address[]", "name": "removeSanctions", "type": "address[]" } ], "name": "removeFromSanctionsList", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "newOwner", "type": "address" } ], "name": "transferOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" } ]

REDDNoC avatar Apr 12 '24 13:04 REDDNoC