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

@turnkey/ethers

Package Overview
Dependencies
Maintainers
1
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turnkey/ethers

Turnkey Signer for Ethers

  • 0.1.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
980
increased by3.7%
Maintainers
1
Weekly downloads
 
Created
Source

@turnkey/ethers

npm

Turnkey Signer for Ethers.

API Docs: https://turnkey.readme.io/

Getting started

$ npm install ethers @turnkey/ethers
import { ethers } from "ethers";
import { TurnkeySigner } from "@turnkey/ethers";

async function main() {
  const network = "goerli";
  const provider = new ethers.providers.InfuraProvider(network);

  const signer = new TurnkeySigner({
    apiPrivateKey: "...",
    apiPublicKey: "...",
    baseUrl: "https://coordinator-beta.turnkey.io",
    keyId: "...",
    organizationId: "...",
  }).connect(provider);

  const chainId = await signer.getChainId();
  const address = await signer.getAddress();
  const balance = await signer.getBalance();

  console.log(`Network\n\t${network} (chainId ${chainId})`);
  console.log(`Address\n\t${address}`);
  console.log(`Balance\n\t${String(balance)}`);

  const transactionRequest = {
    to: "0x2Ad9eA1E677949a536A270CEC812D6e868C88108",
    value: ethers.utils.parseEther("0.001"),
    chainId,
    nonce: 1,
    gasLimit: 21000,
    type: 2,
  };

  const signedTx = await signer.signTransaction(transactionRequest);
  console.log(`Signed transaction\n\t${signedTx}`);

  if (balance.isZero()) {
    console.warn(
      "\nWarning: attempting to send a transaction while account balance is zero\n"
    );
  }

  const sentTx = await signer.sendTransaction(transactionRequest);

  console.log(
    `Transaction sent!\n\thttps://${network}.etherscan.io/tx/${sentTx.hash}`
  );
}

main().catch((error) => {
  console.error(error);
  process.exit(1);
});

Keywords

FAQs

Package last updated on 26 Jan 2023

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