Current collected state Current
Observed since 21 Oct, 09:00 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
@0xkey-io/ethers
0xkey Signer for Ethers
If you need a lower-level, fully typed HTTP client for interacting with ZeroXKey API, check out @0xkey-io/http.
API Docs: https://docs.0xkey.io/
$ npm install ethers @0xkey-io/ethers
import { ethers } from "ethers";
import { ZeroXKeySigner } from "@0xkey-io/ethers";
import { ZeroXKeyClient } from "@0xkey-io/http";
import { ApiKeyStamper } from "@0xkey-io/api-key-stamper";
async function main() {
const network = "goerli";
const provider = new ethers.providers.InfuraProvider(network);
const zeroXKeyClient = new ZeroXKeyClient(
{
baseUrl: "https://api.0xkey.io",
},
// This uses API key credentials.
// If you're using passkeys, use `@0xkey-io/webauthn-stamper` to collect webauthn signatures:
// new WebauthnStamper({...options...})
new ApiKeyStamper({
apiPublicKey: "...",
apiPrivateKey: "...",
}),
);
// Initialize a ZeroXKey Signer
const zeroXKeySigner = new ZeroXKeySigner({
client: zeroXKeyClient,
organizationId: "...",
signWith: "...",
});
// Connect it with a Provider (https://docs.ethers.org/v6/api/providers/)
const connectedSigner = zeroXKeySigner.connect(provider);
const chainId = await connectedSigner.getChainId();
const address = await connectedSigner.getAddress();
const balance = await connectedSigner.getBalance();
const transactionCount = await connectedSigner.getTransactionCount();
console.log(`Network\n\t${network} (chain ID ${chainId})`);
console.log(`Address\n\t${address}`);
console.log(`Balance\n\t${String(balance)}`);
console.log(`Transaction count\n\t${transactionCount}`);
const transactionRequest = {
to: "0x2Ad9eA1E677949a536A270CEC812D6e868C88108",
value: ethers.utils.parseEther("0.0001"),
type: 2,
};
const signedTx = await connectedSigner.signTransaction(transactionRequest);
console.log(`Signed transaction\n\t${signedTx}`);
if (balance.isZero()) {
let warningMessage =
"\nWarning: the transaction won't be broadcasted because your account balance is zero.\n";
if (network === "goerli") {
warningMessage +=
"Use https://goerlifaucet.com/ to request funds on Goerli, then run the script again.\n";
}
console.warn(warningMessage);
return;
}
const sentTx = await connectedSigner.sendTransaction(transactionRequest);
console.log(
`Transaction sent!\n\thttps://${network}.etherscan.io/tx/${sentTx.hash}`,
);
}
main().catch((error) => {
console.error(error);
process.exit(1);
});
See .env.example to get your local testing environment right. Run pnpm jest to run the tests.
| Example | Description |
|---|---|
with-ethers | Create a new Ethereum address, then sign and broadcast a transaction using the Ethers signer with Infura |
with-gnosis | Create new Ethereum addresses, configure a 3/3 Gnosis safe, and create + execute a transaction from it |
with-uniswap | Sign and broadcast a Uniswap v3 trade using the Ethers signer with Infura |
with-nonce-manager | Create a new Ethereum address, then sign and broadcast multiple transactions in a sequential or optimistic manner. |
sweeper | Sweep funds from one address to a different address |
deployer | Compile and deploy a smart contract |
@0xkey-io/http: lower-level fully typed HTTP client for interacting with ZeroXKey APIDownload counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
@0xkey-io/coreEnvironment{
"local_name": "@0xkey-io/core",
"alias": false,
"peer_metadata": null
} | 0.2.0 | runtime |
@0xkey-io/httpEnvironment{
"local_name": "@0xkey-io/http",
"alias": false,
"peer_metadata": null
} | 0.1.2 | runtime |
@0xkey-io/sdk-serverEnvironment{
"local_name": "@0xkey-io/sdk-server",
"alias": false,
"peer_metadata": null
} | 0.1.2 | runtime |
@0xkey-io/sdk-browserEnvironment{
"local_name": "@0xkey-io/sdk-browser",
"alias": false,
"peer_metadata": null
} | 0.1.2 | runtime |
@0xkey-io/api-key-stamperEnvironment{
"local_name": "@0xkey-io/api-key-stamper",
"alias": false,
"peer_metadata": null
} | 0.1.2 | runtime |
ethersEnvironment{
"local_name": "ethers",
"alias": false,
"peer_metadata": null
} | ^6.10.0 | development |
hardhatEnvironment{
"local_name": "hardhat",
"alias": false,
"peer_metadata": null
} | ^2.19.4 | development |
typechainEnvironment{
"local_name": "typechain",
"alias": false,
"peer_metadata": null
} | ^8.3.2 | development |
@typechain/hardhatEnvironment{
"local_name": "@typechain/hardhat",
"alias": false,
"peer_metadata": null
} | ^9.1.0 | development |
@typechain/ethers-v6Environment{
"local_name": "@typechain/ethers-v6",
"alias": false,
"peer_metadata": null
} | ^0.5.1 | development |
@openzeppelin/contractsEnvironment{
"local_name": "@openzeppelin/contracts",
"alias": false,
"peer_metadata": null
} | ^5.0.2 | development |
@nomicfoundation/hardhat-ethersEnvironment{
"local_name": "@nomicfoundation/hardhat-ethers",
"alias": false,
"peer_metadata": null
} | 3.0.5 | development |
@nomicfoundation/hardhat-network-helpersEnvironment{
"local_name": "@nomicfoundation/hardhat-network-helpers",
"alias": false,
"peer_metadata": null
} | ^1.0.8 | development |
ethersEnvironment{
"local_name": "ethers",
"alias": false,
"peer_metadata": null
} | ^6.10.0 | peer |
Source distribution
{
"shasum": "16168ef0881703361653a786fa7a5d019d406313",
"tarball": "https://registry.npmjs.org/@0xkey-io/ethers/-/ethers-0.1.3.tgz",
"fileCount": 10,
"integrity": "sha512-tr8EfF3qOCt+gq4ZVQXQiLt/J+2yQf57V/z0i4Af/x1ybyJ0Wo2OViw6a2UMj7VXABXttA3hEWu59TdciotP2w==",
"signatures": [
{
"sig": "MEQCIF4l58NClR1P6hMVbWFwk8NY2dN4WVzv6nwiejvEQWLqAiAODTPciy8ZeFIP7f0HFKA22lr1Cf9pDOSTmSFh+eTbQQ==",
"keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
}
],
"unpackedSize": 51245
}Observed since 21 Oct, 09:00 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:c970cb4c3cbf3cd0ffa313e6fe19fb6f390ebabdc5e647eaefe16c3eafadc51f