{"id":7120,"date":"2023-03-29T09:15:37","date_gmt":"2023-03-29T09:15:37","guid":{"rendered":"https:\/\/ai.catenacap.xyz\/?page_id=7120"},"modified":"2023-05-13T07:32:06","modified_gmt":"2023-05-13T07:32:06","slug":"elementor-7120","status":"publish","type":"page","link":"https:\/\/ai.catenacap.xyz\/?page_id=7120","title":{"rendered":"Restrict US based Node Validation EVM SmartContract"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-page\" data-elementor-id=\"7120\" class=\"elementor elementor-7120\" data-elementor-post-type=\"page\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-bd702a7 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"bd702a7\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-3bb81c5\" data-id=\"3bb81c5\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-43da6d9 elementor-widget elementor-widget-heading\" data-id=\"43da6d9\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Restrict EVM from processing transactions on a US Based Validator\/Minor Node.<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-6a47dba elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"6a47dba\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-3c1a635\" data-id=\"3c1a635\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-ed71690 elementor-widget elementor-widget-text-editor\" data-id=\"ed71690\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p dir=\"auto\">The following mechanism added into your smart contract&#8217;s will add the function to reject validation or mining from nodes located in the United States<strong>[1],[2],[3]<\/strong>.<\/p><p dir=\"auto\"><strong>[1]<\/strong>\u00a0Understand this is not specific to the US, due to regulatory lack of clarity, it would be prudent to cut the US from validation processes for validating transactions\/smart-contracts processes in the US so as to avoid regulatory action against the project\/company\/developer.<\/p><p dir=\"auto\"><strong>[2]<\/strong>\u00a0Replace US with or addition to other countries you wish to restrict from processing your transactions\/smart-contract processes.<\/p><p dir=\"auto\"><strong>[3]<\/strong> Look for (advisable) friendly states where there is no concern for regulatory attacks based on 1 or % of transactions processing through validators\/miners in those states (suggestions : BVI, Thailand, Singapore, UAE, Bahamas, Malaysia).<\/p><p dir=\"auto\"><strong>1)<\/strong>\u00a0Start by importing the necessary Ethereum libraries and defining the contract:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-997e55c elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"997e55c\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-12b0f83\" data-id=\"12b0f83\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-b6dfbb6 elementor-widget elementor-widget-code-highlight\" data-id=\"b6dfbb6\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"prismjs-default copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-javascript line-numbers\">\n\t\t\t\t<code readonly=\"true\" class=\"language-javascript\">\n\t\t\t\t\t<xmp>pragma solidity ^0.8.0;\n\ncontract USValidationRestriction { \/\/ Declare the state variables and functions here }<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-3faa561 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"3faa561\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-681e749\" data-id=\"681e749\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-a68ca03 elementor-widget elementor-widget-text-editor\" data-id=\"a68ca03\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<ol dir=\"auto\" start=\"2\">\n<li>Declare a mapping that associates IP addresses with their corresponding countries. You can use a public API such as ipstack.com or ipapi.com to retrieve this information. Make sure to declare the mapping as private to prevent external access: csharp<\/li>\n<\/ol>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-6e89c84 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"6e89c84\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-c0e0fa9\" data-id=\"c0e0fa9\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-ed06b89 elementor-widget elementor-widget-code-highlight\" data-id=\"ed06b89\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"prismjs-default copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-javascript line-numbers\">\n\t\t\t\t<code readonly=\"true\" class=\"language-javascript\">\n\t\t\t\t\t<xmp>mapping (string => string) private _ipCountry;<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-14a7adf elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"14a7adf\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-f919975\" data-id=\"f919975\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-c43e9dc elementor-widget elementor-widget-text-editor\" data-id=\"c43e9dc\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<ol dir=\"auto\" start=\"3\"><li>Create a function to update the IP-country mapping. This function should be restricted to the contract owner, who has the authority to add or remove IP addresses as necessary. For example: csharp<\/li><\/ol>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-1d82491 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"1d82491\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-3a5a688\" data-id=\"3a5a688\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-94930fe elementor-widget elementor-widget-code-highlight\" data-id=\"94930fe\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"prismjs-default copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-javascript line-numbers\">\n\t\t\t\t<code readonly=\"true\" class=\"language-javascript\">\n\t\t\t\t\t<xmp>function updateIpCountryMapping(string memory ipAddress, string memory country) public onlyOwner { _ipCountry[ipAddress] = country; }<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-ff50a41 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"ff50a41\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-0fb2db8\" data-id=\"0fb2db8\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-01bb2e2 elementor-widget elementor-widget-text-editor\" data-id=\"01bb2e2\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<ol dir=\"auto\" start=\"4\"><li>Define a modifier that restricts access to certain functions based on the IP-country mapping. This modifier should check if the IP address of the node that is validating or mining the contract is located in the United States. If so, it should revert the transaction and prevent the contract from being executed. For example: less<\/li><\/ol>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-5e3c5f7 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"5e3c5f7\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-0d25c56\" data-id=\"0d25c56\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-0c9cd29 elementor-widget elementor-widget-code-highlight\" data-id=\"0c9cd29\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"prismjs-default copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-javascript line-numbers\">\n\t\t\t\t<code readonly=\"true\" class=\"language-javascript\">\n\t\t\t\t\t<xmp>modifier onlyNonUS() { string memory country = _ipCountry[tx.origin]; require(keccak256(bytes(country)) != keccak256(bytes(\"United States\")), \"US-based node detected.\"); _; }<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-6218002 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"6218002\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-bcd09f4\" data-id=\"bcd09f4\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-e5dad09 elementor-widget elementor-widget-text-editor\" data-id=\"e5dad09\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<ol dir=\"auto\" start=\"5\"><li>Apply the onlyNonUS modifier to the functions that you want to restrict to non-US nodes. For example: csharp<\/li><\/ol>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-986f4b7 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"986f4b7\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-893f6da\" data-id=\"893f6da\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-33f499a elementor-widget elementor-widget-code-highlight\" data-id=\"33f499a\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"prismjs-default copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-javascript line-numbers\">\n\t\t\t\t<code readonly=\"true\" class=\"language-javascript\">\n\t\t\t\t\t<xmp>function myRestrictedFunction() public onlyNonUS { \/\/ This function can only be called from nodes located outside the United States \/\/ ... }<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-215152e elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"215152e\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-3e5b5dc\" data-id=\"3e5b5dc\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-d32b3dd elementor-widget elementor-widget-text-editor\" data-id=\"d32b3dd\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>By using this approach, you can ensure that your smart contract only operates from nodes that are located outside the United States, as required by your regulatory requirements.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-1af31b5 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"1af31b5\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-49fa706\" data-id=\"49fa706\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-d5f8f6a elementor-widget elementor-widget-code-highlight\" data-id=\"d5f8f6a\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"prismjs-default copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-javascript line-numbers\">\n\t\t\t\t<code readonly=\"true\" class=\"language-javascript\">\n\t\t\t\t\t<xmp>pragma solidity ^0.8.0;\n\ncontract USValidationRestriction { mapping (string => string) private _ipCountry; address private _owner;\n\nconstructor() {\n    _owner = msg.sender;\n}\n\nmodifier onlyOwner() {\n    require(msg.sender == _owner, \"Only the contract owner can call this function.\");\n    _;\n}\n\nmodifier onlyNonUS() {\n    string memory country = _ipCountry[tx.origin];\n    require(keccak256(bytes(country)) != keccak256(bytes(\"United States\")), \"US-based node detected.\");\n    _;\n}\n\nfunction updateIpCountryMapping(string memory ipAddress, string memory country) public onlyOwner {\n    _ipCountry[ipAddress] = country;\n}\n\nfunction myRestrictedFunction() public onlyNonUS {\n    \/\/ This function can only be called from nodes located outside the United States\n    \/\/ ...\n}\n}<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-3bdf52a elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"3bdf52a\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-7623638\" data-id=\"7623638\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-bcbe61e elementor-widget elementor-widget-text-editor\" data-id=\"bcbe61e\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p dir=\"auto\">The &#8216;<strong>onlyOwner<\/strong>&#8216; modifier restricts access to the &#8216;<strong>updateIpCountryMapping<\/strong>&#8216; function to the contract owner, who has the authority to update the IP-country mapping.<\/p><p dir=\"auto\">The &#8216;<strong>onlyNonUS<\/strong>&#8216; modifier checks if the IP address of the node that is calling the function is located in the United States. If so, it reverts the transaction and prevents the function from being executed.<\/p><p dir=\"auto\">The &#8216;<strong>myRestrictedFunction<\/strong>&#8216; function is an example of a function that is restricted to non-US nodes. It can only be called from nodes located outside the United States.<\/p><p dir=\"auto\">You can customize the IP-country mapping and the country name used in the &#8216;<strong>onlyNonUS<\/strong>&#8216; modifier to meet your specific regulatory requirements. Also, keep in mind that this approach relies on the accuracy and reliability of the external API used to retrieve the country information, so you should choose a reputable and trustworthy provider.<\/p><h6 dir=\"auto\"><strong>How does it check the IP address of the validator node?<\/strong><\/h6><p dir=\"auto\">The IP address of the validator or miner is retrieved through the <strong>tx.origin<\/strong> variable, which represents the address of the sender of the transaction that triggered the function call.<\/p><p dir=\"auto\">When a validator or miner submits a transaction to the Ethereum network, they include their IP address in the transaction payload. The <strong>tx.origin<\/strong> variable allows you to retrieve this information and use it to determine the country of origin of the node.<\/p><p dir=\"auto\">The IP address is then used as a key in the <strong>_ipCountry<\/strong> mapping to retrieve the corresponding country value. If the country is detected as &#8220;United States&#8221;, the <strong>onlyNonUS<\/strong> modifier reverts the transaction and prevents the function from being executed.<\/p><p dir=\"auto\">Note that this approach relies on the accuracy and reliability of the <strong>IP-country<\/strong> mapping and external APIs used to retrieve this information. It&#8217;s also possible for malicious actors to spoof their IP addresses or use proxy servers to bypass this restriction. Therefore, you should use this mechanism in combination with other security measures to ensure the integrity and safety of your smart contract.<\/p><p dir=\"auto\">Visit our <a href=\"https:\/\/github.com\/catenacap\/restrict_evm_US_other_validation\" target=\"_blank\" rel=\"noopener\">Github<\/a>.<\/p><p dir=\"auto\">\u00a0<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Restrict EVM from processing transactions on a US Based Validator\/Minor Node. The following mechanism added into your smart contract&#8217;s will add the function to reject validation or mining from nodes located in the United States[1],[2],[3]. [1]\u00a0Understand this is not specific to the US, due to regulatory lack of clarity, it would be prudent to cut [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"elementor_theme","meta":{"_acf_changed":false,"disable_featured_image":false,"footnotes":""},"class_list":["post-7120","page","type-page","status-publish","hentry"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Restrict US based Node Validation EVM SmartContract - AI | Catena Cap<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ai.catenacap.xyz\/?page_id=7120\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Restrict US based Node Validation EVM SmartContract - AI | Catena Cap\" \/>\n<meta property=\"og:description\" content=\"Restrict EVM from processing transactions on a US Based Validator\/Minor Node. The following mechanism added into your smart contract&#8217;s will add the function to reject validation or mining from nodes located in the United States[1],[2],[3]. [1]\u00a0Understand this is not specific to the US, due to regulatory lack of clarity, it would be prudent to cut [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ai.catenacap.xyz\/?page_id=7120\" \/>\n<meta property=\"og:site_name\" content=\"AI | Catena Cap\" \/>\n<meta property=\"article:modified_time\" content=\"2023-05-13T07:32:06+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@CatenaCap\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/ai.catenacap.xyz\\\/?page_id=7120\",\"url\":\"https:\\\/\\\/ai.catenacap.xyz\\\/?page_id=7120\",\"name\":\"Restrict US based Node Validation EVM SmartContract - AI | Catena Cap\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ai.catenacap.xyz\\\/#website\"},\"datePublished\":\"2023-03-29T09:15:37+00:00\",\"dateModified\":\"2023-05-13T07:32:06+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/ai.catenacap.xyz\\\/?page_id=7120#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/ai.catenacap.xyz\\\/?page_id=7120\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/ai.catenacap.xyz\\\/?page_id=7120#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/ai.catenacap.xyz\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Restrict US based Node Validation EVM SmartContract\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/ai.catenacap.xyz\\\/#website\",\"url\":\"https:\\\/\\\/ai.catenacap.xyz\\\/\",\"name\":\"AI | Catena Cap\",\"description\":\"Don&#039;t Trust, Verify\",\"publisher\":{\"@id\":\"https:\\\/\\\/ai.catenacap.xyz\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/ai.catenacap.xyz\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/ai.catenacap.xyz\\\/#organization\",\"name\":\"AI | CatenaCap\",\"url\":\"https:\\\/\\\/ai.catenacap.xyz\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/ai.catenacap.xyz\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/bafybeihf3j3elacorgnhodcdk4nnenm63rag6p777elx52d5xwpkmm5rfi.ipfs.dweb.link\\\/uploads\\\/2023\\\/02\\\/occ-fav-150x150-1.png\",\"contentUrl\":\"https:\\\/\\\/bafybeihf3j3elacorgnhodcdk4nnenm63rag6p777elx52d5xwpkmm5rfi.ipfs.dweb.link\\\/uploads\\\/2023\\\/02\\\/occ-fav-150x150-1.png\",\"width\":150,\"height\":150,\"caption\":\"AI | CatenaCap\"},\"image\":{\"@id\":\"https:\\\/\\\/ai.catenacap.xyz\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/x.com\\\/CatenaCap\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Restrict US based Node Validation EVM SmartContract - AI | Catena Cap","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/ai.catenacap.xyz\/?page_id=7120","og_locale":"en_US","og_type":"article","og_title":"Restrict US based Node Validation EVM SmartContract - AI | Catena Cap","og_description":"Restrict EVM from processing transactions on a US Based Validator\/Minor Node. The following mechanism added into your smart contract&#8217;s will add the function to reject validation or mining from nodes located in the United States[1],[2],[3]. [1]\u00a0Understand this is not specific to the US, due to regulatory lack of clarity, it would be prudent to cut [&hellip;]","og_url":"https:\/\/ai.catenacap.xyz\/?page_id=7120","og_site_name":"AI | Catena Cap","article_modified_time":"2023-05-13T07:32:06+00:00","twitter_card":"summary_large_image","twitter_site":"@CatenaCap","twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/ai.catenacap.xyz\/?page_id=7120","url":"https:\/\/ai.catenacap.xyz\/?page_id=7120","name":"Restrict US based Node Validation EVM SmartContract - AI | Catena Cap","isPartOf":{"@id":"https:\/\/ai.catenacap.xyz\/#website"},"datePublished":"2023-03-29T09:15:37+00:00","dateModified":"2023-05-13T07:32:06+00:00","breadcrumb":{"@id":"https:\/\/ai.catenacap.xyz\/?page_id=7120#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ai.catenacap.xyz\/?page_id=7120"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/ai.catenacap.xyz\/?page_id=7120#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ai.catenacap.xyz\/"},{"@type":"ListItem","position":2,"name":"Restrict US based Node Validation EVM SmartContract"}]},{"@type":"WebSite","@id":"https:\/\/ai.catenacap.xyz\/#website","url":"https:\/\/ai.catenacap.xyz\/","name":"AI | Catena Cap","description":"Don&#039;t Trust, Verify","publisher":{"@id":"https:\/\/ai.catenacap.xyz\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ai.catenacap.xyz\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/ai.catenacap.xyz\/#organization","name":"AI | CatenaCap","url":"https:\/\/ai.catenacap.xyz\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ai.catenacap.xyz\/#\/schema\/logo\/image\/","url":"https:\/\/bafybeihf3j3elacorgnhodcdk4nnenm63rag6p777elx52d5xwpkmm5rfi.ipfs.dweb.link\/uploads\/2023\/02\/occ-fav-150x150-1.png","contentUrl":"https:\/\/bafybeihf3j3elacorgnhodcdk4nnenm63rag6p777elx52d5xwpkmm5rfi.ipfs.dweb.link\/uploads\/2023\/02\/occ-fav-150x150-1.png","width":150,"height":150,"caption":"AI | CatenaCap"},"image":{"@id":"https:\/\/ai.catenacap.xyz\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/CatenaCap"]}]}},"_links":{"self":[{"href":"https:\/\/ai.catenacap.xyz\/index.php?rest_route=\/wp\/v2\/pages\/7120","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ai.catenacap.xyz\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/ai.catenacap.xyz\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/ai.catenacap.xyz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ai.catenacap.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7120"}],"version-history":[{"count":0,"href":"https:\/\/ai.catenacap.xyz\/index.php?rest_route=\/wp\/v2\/pages\/7120\/revisions"}],"wp:attachment":[{"href":"https:\/\/ai.catenacap.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7120"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}