Resolution between Fid and Address

Get Fid from an Ethereum address and vice versa directly in your smart contract. Reimagine the identity.

FID from Address

Get the FID from the farcaster verfifed address list.
function getFidByVerifiedAddress(address _address) external view returns (uint256 fid);
YourContract.sol
1// Import the Faracle interface
2import "./IFaracle.sol";
3
4contract Whitelist {
5
6  mapping(uint256 => bool) public whitelisted;
7
8  IFaracle public faracle = IFaracle(0x687d65ce04abbca3dac57cda6c358e497bfd320e);
9
10  constructor() {}
11
12  function whitelistMe() public {
13
14    // Get the FID associated with the sender's address
15    uint256 fid = faracle.getFidByVerifiedAddress(msg.sender);
16
17    // Ensure the address is linked to a FID
18    require(fid != 0, "Address not linked to any FID!");
19
20    // Check if the FID is already whitelisted
21    require(!whitelisted[fid], "FID already whitelisted!");
22    
23    // Whitelist the FID
24    whitelisted[fid] = true;
25  }
26
27}

Get all verified Addresses from FID

Get all verified addresses associated with a Farcaster FID.
function getVerifiedAddressesByFid(uint256 _fid) external view returns (address[] memory);
YourContract.sol
1// Import the Faracle interface
2import "./IFaracle.sol";
3
4contract GetAddresses {
5  
6  IFaracle public faracle = IFaracle(0x687d65ce04abbca3dac57cda6c358e497bfd320e);
7
8  constructor() {}
9
10  function getAddresses(uint256 fid) public view returns (address[] memory) {
11
12    // Get all of verified addresses associated with the FID
13    address[] memory addresses = faracle.getVerifiedAddressesByFid(fid);
14
15    return addresses;
16  }
17
18}
Note: The first item in the address list is considered the primary address.

Get all verified Addresses from Address

Get all verified addresses associated with a Farcaster Profile by an address.
function getLinkedAddresses(address _address) external view returns (address[] memory);
YourContract.sol
1// Import the Faracle interface
2import "./IFaracle.sol";
3
4contract GetAddresses {
5  
6  IFaracle public faracle = IFaracle(0x687d65ce04abbca3dac57cda6c358e497bfd320e);
7
8  constructor() {}
9
10  function getAddresses(address _address) public view returns (address[] memory) {
11
12    // Get all of verified addresses associated with the address
13    address[] memory addresses = faracle.getLinkedAddresses(_address);
14
15    return addresses;
16  }
17
18}
Note: The first item in the address list is considered the primary address.

Primary Address from FID

Get the primary verified address associated with a Farcaster FID.
function getPrimaryAddressByFid(uint256 _fid) external view returns (address primaryAddress);
YourContract.sol
1// Import the Faracle interface
2import "./IFaracle.sol";
3
4contract GetPrimaryAddress {
5  
6  IFaracle public faracle = IFaracle(0x687d65ce04abbca3dac57cda6c358e497bfd320e);
7
8  constructor() {}
9
10  function getPrimaryAddress(uint256 _fid) public view returns (address _primaryAddress) {
11
12    // Get the primary verified address associated with the FID
13    _primaryAddress = faracle.getPrimaryAddressByFid(_fid);
14  }
15
16}

Get Other Addresses from FID

Get other addresses like custody and recovery addresses associated with a Farcaster FID.
function getOtherAddressByFid(uint256 _fid, uint256[] calldata _indexes) external view returns (address[] memory);
YourContract.sol
1// Import the Faracle interface
2import "./IFaracle.sol";
3import "./FaracleHelper.sol";
4
5contract GetOtherAddress {
6  
7  IFaracle public faracle = IFaracle(0x687d65ce04abbca3dac57cda6c358e497bfd320e);
8
9  constructor() {}
10
11  function getCustodyAndRecoveryAddress(uint256 _fid) public view returns (address _custody, address _recovery) {
12
13    // Get recovery and custody addresses associated with the FID
14    (_custody, _recovery) = faracle.getOtherAddressByFid(_fid, [FaracleHelper.ADDRESS_CUSTODY, FaracleHelper.ADDRESS_RECOVERY]);
15    
16  }
17
18}

Get Other Address from FID

Get other address like custody and recovery addresses associated with a Farcaster FID.
function getOtherAddressByFid(uint256 _fid, uint256 _index) external view returns (address);
YourContract.sol
1// Import the Faracle interface
2import "./IFaracle.sol";
3import "./FaracleHelper.sol";
4
5contract GetOtherAddress {
6  
7  IFaracle public faracle = IFaracle(0x687d65ce04abbca3dac57cda6c358e497bfd320e);
8
9  constructor() {}
10
11  function getCustodyAddress(uint256 _fid) public view returns (address _custody) {
12
13    // Get the custody address associated with the FID
14    _custody = faracle.getOtherAddressByFid(_fid, FaracleHelper.ADDRESS_CUSTODY);
15    
16  }
17
18}