ens-proxy-sdk
Advanced tools
Comparing version 0.0.7 to 0.0.8
{ | ||
"name": "ens-proxy-sdk", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "SDK for interacting with smart contracts via an ENS proxy", |
@@ -34,19 +34,3 @@ # ENS Proxy SDK | ||
This same address is used across Mainnet, Ropsten, Rinkeby and Goerli. | ||
- An example of creating your own OwnableEnsProxy: | ||
```ts | ||
const signer = ethers.provider.getSigner(); | ||
const ownableEnsProxyFactory = new Contract( | ||
OWNABLE_ENS_PROXY_FACTORY_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 | ||
@@ -72,19 +56,53 @@ | ||
Example of using PublicEnsProxy: | ||
```ts | ||
import { SafeEns, PUBLIC_ENS_PROXY_ADDRESS } from "ens-proxy-sdk"; | ||
import { ethers } from "ethers"; | ||
const signer = ethers.provider.getSigner(); | ||
const safeEns = new SafeEns(PUBLIC_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, | ||
// Use public ens to send eth to omarsayha.eth | ||
const publicSafeEns = new SafeEns(PUBLIC_ENS_PROXY_ADDRESS, signer); | ||
const publicSendEthTx = await publicSafeEns.sendEth( | ||
"omarsayha.eth", | ||
"100000000000000000", // NOTE: units are in wei | ||
); | ||
// Interact with a contract using the proxy: | ||
const tx1 = await contract.yourMintMethod("omarsayha.eth"); | ||
await publicSendEthTx.wait(); | ||
``` | ||
// Interact with a contract without using the proxy: | ||
const tx2 = await contract.baseContract.yourTransferMethod("omarsayha.eth"); | ||
Example of using your own OwnableEnsProxy: | ||
```ts | ||
import { | ||
SafeEns, | ||
OwnableEnsProxyFactory, | ||
OwnableEnsProxyCreatedEvent, | ||
OwnableEnsProxyFactoryJson, | ||
OWNABLE_ENS_PROXY_FACTORY_ADDRESS, | ||
} from "ens-proxy-sdk"; | ||
import { ethers } from "ethers"; | ||
const signer = ethers.provider.getSigner(); | ||
// Create your own ownable ens proxy | ||
const ownableEnsProxyFactory = new Contract( | ||
OWNABLE_ENS_PROXY_FACTORY_ADDRESS, | ||
OwnableEnsProxyFactoryJson.abi, | ||
signer, | ||
) as OwnableEnsProxyFactory; | ||
await ownableEnsProxyFactory.deployed(); | ||
const createEnsProxyTx = await ownableEnsProxyFactory | ||
.connect(signer) | ||
.createEnsProxy(); | ||
const createEnsProxyTxReceipt = await createEnsProxyTx.wait(); | ||
const { ensProxyAddress } = ( | ||
createEnsProxyTxReceipt.events?.[0] as OwnableEnsProxyCreatedEvent | ||
).args; | ||
// Use the created ownable ens proxy to send eth | ||
const ownableSafeEns = new SafeEns(ensProxyAddress, signer); | ||
const ownableSendEthTx = await ownableSafeEns.sendEth( | ||
"omarsayha.eth", | ||
"100000000000000000", // NOTE: units are in wei | ||
); | ||
await ownableSendEthTx.wait(); | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1192261
107