Verifying a trusted location proof on-chain consists of a call to the IoTeX location Verifier contract.
The official Verifier Contracts are deployed to the following addresses:
Network
Address
Verifier Contract
IoTeX Testnet
0xB9ae925fF8318915e3266e0EA41a37408033caC6
Verifier Contract
IoTeX Mainnet
0x539057424d2A1A0B7D7Af6F322f34569b967b272
Using the Verifier
From inside your smart contract, you can import the deployed instance of the Verifier like below:
pragmasolidity ^0.8.0;import"../interface/IGeoLocationDataVerifier.sol";IGeoLocationDataVerifier public verifier;contract YourContractName { IGeoLocationDataVerifier public verifier;// Construct the contract using the official GeoStream Verifier addressconstructor(address_verifier) { verifier =IGeoLocationDataVerifier(_verifier); }// ... }
You should then use the Verifier in the section of your contract logic where the Proof of Location is required:
// ...function_someLogicThatNeedsProofOfLocation(address deviceowner,int256 latitude,int256 longitude,uint256 distance,bytes32 deviceHash,uint256 fromTimestamp,uint256 toTimestamp,bytesmemory signature ) {// Generate the hash of the proofbytes32 digest = verifier.generateLocationDistanceDigest( deviceOwner, latitude, longitude, distance, deviceHash, fromTimestamp, toTimestamp);// Require the proof is validrequire(verifier.verify(digest, signature),"Invalid proof signature");// Your custom logic here// ...
Learn more: Verifier Contract Source
The source code of the Verifier contract can be found on GitHub: