money-simple-from-bracketSigning Transactions

npm versionarrow-up-rightLicense: GPL-3.0arrow-up-rightGitHub starsarrow-up-right

The Multicahain Wallet Connector tool enables developers to seamlessly integrate Ethereum-compatible transaction signing into their dApps. This section guides you through how to perform this task using two primary environments:

  • Framework-based environments (e.g., Webpack, Vite, Next.js)

  • CommonJS / Vanilla HTML via CDN (ideal for rapid prototyping or lightweight apps)

πŸ“¦ 1. Framework Usage

πŸ“ Installation

First, install the NPM library in your project:

Or if you use Yarn:

This will:

  • Add the library to your node_modules

  • Automatically include all required dependencies (e.g., ethers.js, js-sha3)

  • Enable both ES Module (import) and CommonJS (require) usage

🧠 Code Example (Framework/ES6)

Here's a minimal setup for connecting to a wallet and signing a transaction:

For typescript users, declare as a module in your types file:

πŸ’‘ Notes

  • Always check for wallet connection before signing.

  • Pass in the correct chainId (e.g., 10 for Optimism).

🌐 2. CommonJS via CDN (HTML/Vanilla JS)

For static or simple projects, include the WalletConnector SDK via CDN

βœ… Embedding the Script

Ensure this is added before your custom scripts in the HTML body.

🧠 Code Example (CDN/Vanilla JS)

πŸ›  Best Practices

  • Always confirm the user’s network before submitting a transaction.

  • Catch and handle user rejection errors gracefully.

  • Display a loader or toast notification while the transaction is pending.

  • Validate ETH input and addresses on the frontend before passing to signTransaction.

πŸ“¬ Conclusion

This library abstracts away complex provider logic while preserving full control over EVM-compatible transactions. Whether you're working with a complex JavaScript framework or just plain HTML, signing transactions is quick and reliable using the approaches outlined above.

Last updated