
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@turnkey/ethers
Advanced tools
If you need a lower-level, fully typed HTTP client for interacting with Turnkey API, check out @turnkey/http
.
API Docs: https://docs.turnkey.com/
$ npm install ethers @turnkey/ethers
import { ethers } from "ethers";
import { TurnkeySigner } from "@turnkey/ethers";
import { TurnkeyClient } from "@turnkey/http";
import { ApiKeyStamper } from "@turnkey/api-key-stamper";
async function main() {
const network = "goerli";
const provider = new ethers.providers.InfuraProvider(network);
const turnkeyClient = new TurnkeyClient(
{
baseUrl: "https://api.turnkey.com",
},
// This uses API key credentials.
// If you're using passkeys, use `@turnkey/webauthn-stamper` to collect webauthn signatures:
// new WebauthnStamper({...options...})
new ApiKeyStamper({
apiPublicKey: "...",
apiPrivateKey: "...",
})
);
// Initialize a Turnkey Signer
const turnkeySigner = new TurnkeySigner({
client: turnkeyClient,
organizationId: "...",
signWith: "...",
});
// Connect it with a Provider (https://docs.ethers.org/v5/api/providers/)
const connectedSigner = turnkeySigner.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 |
@turnkey/http
: lower-level fully typed HTTP client for interacting with Turnkey APIFAQs
Turnkey Signer for Ethers
The npm package @turnkey/ethers receives a total of 562 weekly downloads. As such, @turnkey/ethers popularity was classified as not popular.
We found that @turnkey/ethers demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.