Skip to content
Information Circle

The Spanning Demo App is live! Check it out here: https://demo.spanning.network/

We have also published the open-source demo code and related JavaScript utilities.

Spanning NFTs

The fastest and easiest way to integrate with the Spanning Network is to use the Spanning version of the base contract class you are inheriting from. Spanning Labs has built out support for many OpenZeppelin classes and their extensions such as:

This enables a user on any chain to own your NFT directly, without any third-party custody and without any wrapping. They get the same functionality and the same exclusive access to ownerOnly functions that they would if they were on the same chain as the NFT.

Integration

Here is an example of the one-line change needed to update your contract to a Spanning base class:

- import "@openzeppelin/contracts/token/ERC721/presets/ERC721.sol"
+ import "@spanning/contracts/token/ERC721/presets/SpanningERC721.sol"

Here is an example constructor from this demo app that can be used to pass in the Spanning Delegate address as well as other standard ERC721 parameters:

    /**
     * @dev Creates the contract, initializing various base contracts
     *
     * @param delegate_ - Chain-local address of our Spanning Delegate
     */
    constructor(address delegate_)
        SpanningERC721("Jade Spanning Non-fungible Token", "JADENFT", delegate_)
    {}

What does this do?

This does two things:

  1. Changes ownership fields in your contract from storing the legacy address type address to a multichain capable address type SpanningAddress is bytes32.
  2. Allows you to define an address for the local Spanning Delegate contract. The Spanning Delegate receives multichain messages and serves the local domain ID, Spanning message sender, and Spanning transaction origin to your application. The local Spanning Delegate contract address is passed into the constructor on deployment and can be updated by the owner of the contract to upgrade to new versions.

Extensions

Using a Spanning base class for your application may be the only change you need to make your application multichain capable! You can take advantage of common ERC contract extension types to get even more functionality like:

  • Mintable
  • Burnable
  • Pausable
  • Upgradeable
  • Etc…

If there is a common base class extension that you would like to use that isn’t yet included in the @Spanning NPM package. Please make a request to @Spanning Labs on the #developers channel of our Discord.