0.0.1-beta-2 • Published 1 year ago

@xessential/contracts v0.0.1-beta-2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@0xessential/contracts

This repo contains the Solidity source code for the contracts used in 0xEssential's Cross-Chain Token Gating meta-transaction stack.

The contracts are available as an NPM package and can also be installed as a Foundry dependency.

0xEssential provides deployed versions of EssentialForwarder on Polygon's Mumbai testnet and Matic mainnet.

Developers are also free to deploy their own versions of EssentialForwarder - you may want to deploy your own version so that you can change the domainName that is displayed to users when signing a meta-transaction with their wallet.

Install

With NPM:

  yarn add @0xessential/contracts

With Foundry:

Then add the following line to your remappings.txt:

essential-contracts/=lib/essential-contracts/

Use Deployed Instances

If you're building a layer 2 contract that uses Cross-Chain Token Gating and don't wish to customize the domain name displayed to users, you need to inherit EssentialContext in your contract. We also provide EssentialContextUpgradeable if your contract is an upgradeable proxy.

pragma solidity ^0.8.13;

import "essential-contracts/contracts/fwd/EssentialContext.sol";

contract MyContract is EssentialContext {}

Then add the EssentialContext constructor call:

  constructor(address trustedForwarder) EssentialContext(trustedForwarder) {

The deployed EssentialForwarder instances are available at the following addresses. You will need the name value in your frontend.

NetworkAddressname
Mumbai0x9928351FD354D4E45416fc53e90457a428960cF40xEssential Playsession
Mainnet0x9bbb4217115B7296630183Bb23703DEC93E8edCf0xEssential Playsession

Deploy Your Own

If you require customizing the name of the forwarder shown to users when signing meta-transactions, you need to deploy your own version of an EssentialForwarder.

You can do this by creating your own contract that inherits EssentialForwarder and calls its constructor with your custom name:

pragma solidity ^0.8.13;

import "@0xessential/contracts/fwd/EssentialForwarder.sol";

contract MyCustomForwarder is EssentialForwarder {
  constructor(string[] memory _urls) 
  EssentialForwarder("My Custom Forwarder Name", _urls)
  {}
}

The _urls constructor argument is an array of HTTPS URLs that serve 0xEssential's open source Ownership Lookup RPC API.

You may specify the instance 0xEssential runs - https://middleware.nfight.xyz or see that repo for deploying your own version.

0.0.1-beta-2

1 year ago

0.0.1-beta-1

1 year ago