Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ens-proxy-sdk

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ens-proxy-sdk

SDK for interacting with smart contracts via an ENS proxy

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

ENS Proxy SDK

Ethers client extended with on-chain ENS resolution using either a PublicEnsProxy or OwnableEnsProxy, depending on your use case.

Introduction

When resolving ENS names, you probably make a call to the ENS registry/resolver to get an address and then you execute a transaction using that address. Although uncommon, this makes you vulnerable to MITM (man in the middle) attacks, deep reorgs or any other possible attack vectors that lead to a dirty read. With the ENS proxy SDK, you can be confident that any interaction with, say "omarsayha.eth", is in fact directed to the owner of "omarsayha.eth".

There are two types of contracts that you can use to make this interaction, both with the same interface but different privileges:

PublicEnsProxy:

  • This contract is accessible by anyone. As such, you should NOT give this contract any privileges. For example, you should NOT approve() ownership to transfer an ERC20 token. Some great example use cases are sending ETH to "omarsayha.eth" or using approveAndCall() to transfer ERC20 tokens to an ERC1363 compliant token
  • The PublicEnsProxy is deployed at TODO_ADDRESS. This same address is used across Mainnet, Ropsten, Rinkeby and Goerli.

OwnableEnsProxy:

  • This contract is accessible by only the owner, using OpenZepplin's Ownable. To create your own ownable ens proxy, using the OwnableEnsProxyFactory.
  • The OwnableEnsProxyFactory is deployed at TODO_ADDRESS. This same address is used across Mainnet, Ropsten, Rinkeby and Goerli.
  • An example of creating your own OwnableEnsProxy:
const signer = ethers.provider.getSigner();
const ownableEnsProxyFactory = new Contract(
  TODO_ADDRESS,
  ownableEnsProxyJson.abi,
  signer,
) as OwnableEnsProxyFactory;
await ownableEnsProxyFactory.deployed();
const tx = await ownableEnsProxyFactory.connect(signer).createEnsProxy();
const receipt = await tx.wait();
const { ensProxyAddress } = (receipt.events?.[0] as OwnableEnsProxyCreatedEvent)
  .args;
const ownableSafeEns = new SafeEns(ensProxyAddress, signer);

Installation

With a package manager

With Yarn:

yarn add @ens-proxy-sdk

Or with NPM:

npm install @ens-proxy-sdk

Usage

Basic Usage

const ENS_PROXY_ADDRESS = TODO_ADDRESS; // either the PublicEnsProxy address or your OwnableEnsProxy address
const signer = ethers.provider.getSigner();
const safeEns = new SafeEns(ENS_PROXY_ADDRESS, signer);
// Send eth (NOTE: units are in wei):
safeEns.sendEth("omarsayha.eth", "100000000000000000");

// NOTE: Since there are thousands of smart contracts you can interact with,
// the following example expects you to replace everything starting with YOUR
const contract = safeEns.newContract<YourContractType>(
  yourContractAddress,
  yourContractAbi,
);
// Interact with a contract using the proxy:
const tx1 = await contract.yourMintMethod("omarsayha.eth");

// Interact with a contract without using the proxy:
const tx2 = await contract.baseContract.yourTransferMethod("omarsayha.eth");

FAQs

Package last updated on 14 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc