Skip to content

Solidity API

SpanningAddress

This library adds interpretation of our SpanningAddress as follows:

31    27        19                   0
|-----+---------+--------------------|

+The bottom 0-19 bytes are the local address
+Bytes 20-27 are left empty for future expansion
+Bytes 28 - 31 are the domain ID
+Byte 20 - the number of blocks the protocol
           will wait before settling the transaction

create

function create(address legacyAddress, bytes4 domain) public pure returns (bytes32)

Helper function to pack a Spanning Address.

NameTypeDescription
legacyAddressaddress- Legacy (local) address to pack
domainbytes4- Domain identifier to pack
NameTypeDescription
[0]bytes32bytes32 - Generated Spanning Address

invalidAddress

function invalidAddress() public pure returns (bytes32)

Sentinel value for an invalid Spanning Address.

NameTypeDescription
[0]bytes32bytes32 - An invalid Spanning Address

valid

function valid(bytes32 addr) public pure returns (bool)

getAddress

function getAddress(bytes32 input) public pure returns (address)

Extracts legacy (local) address.

NameTypeDescription
inputbytes32- Spanning Address to unpack
NameTypeDescription
[0]addressaddress - Unpacked legacy (local) address

getDomain

function getDomain(bytes32 input) public pure returns (bytes4)

Extracts domain identifier.

NameTypeDescription
inputbytes32- Spanning Address to unpack
NameTypeDescription
[0]bytes4bytes4 - Unpacked domain identifier

equals

function equals(bytes32 first, bytes32 second) public pure returns (bool)

Determines if two Spanning Addresses are equal. Note: This function only considers LegacyAddress and Domain for equality Note: Thus, equals() can return true even if first != second

NameTypeDescription
firstbytes32- the first Spanning Address
secondbytes32- the second Spanning Address
NameTypeDescription
[0]boolbool - true if the two Spanning Addresses are equal

packAddressData

function packAddressData(bytes32 existingAddress, uint8 payload, uint8 index) public pure returns (bytes32)

_Packs data into an existing Spanning Address

This can be used to add routing parameters into a Spanning Addresses buffer space.

Example to specify a message waits numFinalityBlocks before settling: newSpanningAddress = packAddressData(prevSpanningAddress, numFinalityBlocks, 20)_

NameTypeDescription
existingAddressbytes32- the Spanning Address to modify
payloaduint8- the data to pack
indexuint8- the byte location to put the payload into