Humanode Docs
Search…
⌃K

Precompiles

Documentation on the special precompiles that are available at the Humanode Network.

Bioauth status check precompile

Use this precompile to check if the specified address has an active bioauth. Takes the validator public key (type AccountId in the Humanode runtime code, also known as native - or Substrate - account).
Property
Description
Address
0x0000000000000000000000000000000000000800
Input
AccountId (Substrate account address); 32 bytes The public key to check.
Output
bool; 1 byte 1 if bioauth is active for the address, 0 if bioauth is inactive for the address.

Helper Library

You can use the helper library below together with your smart contract code to simplify invoking the precompile.
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
library bioauth {
function isAuthenticated(bytes32 accountId) public view returns (bool result) {
address precompile = 0x0000000000000000000000000000000000000800;
bytes memory payload = abi.encodePacked(accountId);
(bool success, bytes memory returnData) = precompile.staticcall(payload);
assert(success);
assert(returnData.length == 1);
return (returnData[0] != 0);
}
}

EVM to native account mapping precompile

Use this precompile to find a corresponding mapped native AccountId for provided EVM address. This is useful to be used in combination with Bioauth precompile as you don't need to worry about a proper AccountId to do bioauth check.
Description
Property
Description
Address
0x0000000000000000000000000000000000000801
Input
evmAddress (EVM address); 20 bytes
Output
(bool, bytes32);
  • (true, 0x12..9): indicates that the evm adress has been mapped where 0x12..9 is the mapped native account itself.
  • (false, 0x00..0): indicates that the evm addres hasn't been mapped.

Helper Library

You can use the helper library below together with your smart contract code to simplify invoking the precompile.
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
library evmAccounts {
function claimedNativeAccount(bytes20 evmAddress) public view returns (bool, bytes32) {
address precompile = 0x0000000000000000000000000000000000000801;
bytes memory payload = abi.encodePacked(evmAddress);
(bool success, bytes memory returnData) = precompile.staticcall(payload);
assert(success);
if (returnData.length == 0) {
return (false, 0x0);
}
bytes32 nativeAccount = abi.decode(returnData, (bytes32));
return (true, nativeAccount);
}
}