diff --git a/src/README.md b/src/README.md index ad4e4e64..0cb23f42 100644 --- a/src/README.md +++ b/src/README.md @@ -1,260 +1,18 @@ -> :warning: **ALPHA SOFTWARE**: This code relies on the SUAVE protocol, and both are subject to change. Please use it with caution. The [SUAVE spec](https://github.com/flashbots/suave-specs/tree/main) has not yet stabilized, so we are currently refraining from merging this work upstream. [Confidential Compute Requests](https://github.com/flashbots/suave-specs/blob/main/specs/rigil/kettle.md#confidentialcomputerequest) rely on a custom signature scheme, with the option to use EIP-712 to sign the payload. [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193) wallets use either `eth_signTypedData_v4` (EIP-712) or `eth_sign` (generally regarded as unsafe) to sign confidential requests. We recommend always using EIP-712, which is the default. This default can be overridden by setting `isEIP712` in the request being signed. +# ![suave-viem](./suave-viem-logo-white.png) -
+A fork of [viem](https://viem.sh/) for [SUAVE](https://suave-alpha.flashbots.net/). -

- - - - viem logo - - -

+> :warning: **ALPHA SOFTWARE**: This code relies on the SUAVE protocol, and both are subject to change. Please use it with caution. The [SUAVE spec](https://github.com/flashbots/suave-specs/tree/main) has not yet stabilized, so we are currently refraining from merging this work upstream. -

- TypeScript Interface for Ethereum -

+**See the suave examples for usage:** -

- - - - Version - - - - - - Code coverage - - - - - - MIT License - - - - - - Downloads per month - - - - - - Best of JS - - -

+- [examples/suave](./examples/suave/) +- [examples/suave-web-demo](./examples/suave-web-demo/) -
+## about suave -## Features +SUAVE implements a new transaction type: [Confidential Compute Requests](https://github.com/flashbots/suave-specs/blob/main/specs/rigil/kettle.md#confidentialcomputerequest) (CCRs). -- Abstractions over the [JSON-RPC API](https://ethereum.org/en/developers/docs/apis/json-rpc/) to make your life easier -- First-class APIs for interacting with [Smart Contracts](https://ethereum.org/en/glossary/#smart-contract) -- Language closely aligned to official [Ethereum terminology](https://ethereum.org/en/glossary/) -- Import your Browser Extension, WalletConnect or Private Key Wallet -- Browser native [BigInt](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt), instead of large BigNumber libraries -- Utilities for working with [ABIs](https://ethereum.org/en/glossary/#abi) (encoding/decoding/inspection) -- TypeScript ready ([infer types](https://viem.sh/docs/typescript) from ABIs and EIP-712 Typed Data) -- First-class support for [Anvil](https://book.getfoundry.sh/), [Hardhat](https://hardhat.org/) & [Ganache](https://trufflesuite.com/ganache/) -- Test suite running against [forked](https://ethereum.org/en/glossary/#fork) Ethereum network +CCRs rely on a custom signature scheme, with the option to use EIP-712 to sign the payload. -... and a lot lot more. - -## Overview - -First, see these instructions for spinning up a local devnet. Then install **[@flashbots/suave-viem](https://www.npmjs.com/package/@flashbots/suave-viem)** into your project and run this code: - -```ts -import { http, type Hex } from '@flashbots/suave-viem'; -import { suaveToliman as suaveChain } from '@flashbots/suave-viem/chains'; -import { - getSuaveProvider, - getSuaveWallet, - type TransactionRequestSuave, - SuaveTxRequestTypes -} from '@flashbots/suave-viem/chains/utils'; - -// connect to a local SUAVE devnet -const SUAVE_RPC_URL = 'http://localhost:8545'; -const suaveProvider = getSuaveProvider(http(SUAVE_RPC_URL)); - -// instantiate a wallet -const DEFAULT_PRIVATE_KEY: Hex = - '0x91ab9a7e53c220e6210460b65a7a3bb2ca181412a8a7b43ff336b3df1737ce12'; -const wallet = getSuaveWallet({ - transport: http(SUAVE_RPC_URL), - privateKey: DEFAULT_PRIVATE_KEY, -}); - -// Watch for pending transactions -suaveProvider.watchPendingTransactions({ - async onTransactions(transactions) { - for (const hash of transactions) { - try { - console.log( - 'Transaction Receipt:', - await suaveProvider.getTransactionReceipt({hash}) - ); - } catch (error) { - console.error('Error fetching receipt:', error); - } - } - }, -}); - -// send a confidential compute request -const ccr: TransactionRequestSuave = { - confidentialInputs: - '0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000fd7b22626c6f636b4e756d626572223a22307830222c22747873223a5b2230786638363538303064383235323038393461646263653931303332643333396338336463653834316336346566643261393232383165653664383230336538383038343032303131386164613038376337386234353663653762343234386237313565353164326465656236343031363032343832333735663130663037396663666637373934383830653731613035373366336364343133396437323037643165316235623263323365353438623061316361636533373034343739656334653939316362356130623661323930225d2c2270657263656e74223a31307d000000', - kettleAddress: '0xB5fEAfbDD752ad52Afb7e1bD2E40432A485bBB7F', // Address of your local Kettle. Use 0x03493869959C866713C33669cA118E774A30A0E5 if on Rigil. - to: '0x8f21Fdd6B4f4CacD33151777A46c122797c8BF17', - gasPrice: 10000000000n, // Gas price for the transaction - gas: 420000n, // Gas limit for the transaction - type: SuaveTxRequestTypes.ConfidentialRequest, // (0x43) - data: '0x236eb5a70000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000008f21fdd6b4f4cacd33151777a46c122797c8bf170000000000000000000000000000000000000000000000000000000000000000', -}; - -const res = await wallet.sendTransaction(ccr); -console.log(`sent ccr! tx hash: ${res}`); -``` - -See [the docs](https://suave-alpha.flashbots.net/tools/typescript-sdk) and [examples](./examples/) in this repo ([suave](./examples/suave), [suave-web-demo](./examples/suave-web-demo)) for more detailed examples. - -## Community - -Check out the following places for more viem-related content: - -- Follow [@wagmi_sh](https://twitter.com/wagmi_sh), [@jakemoxey](https://twitter.com/jakemoxey), and [@awkweb](https://twitter.com/awkweb) on Twitter for project updates -- Join the [discussions on GitHub](https://github.com/wagmi-dev/viem/discussions) -- [Share your project/organization](https://github.com/wagmi-dev/viem/discussions/104) that uses viem - -## Support - -- [GitHub Sponsors](https://github.com/sponsors/wagmi-dev?metadata_campaign=docs_support) -- [Gitcoin Grant](https://wagmi.sh/gitcoin) -- [wagmi-dev.eth](https://etherscan.io/enslookup-search?search=wagmi-dev.eth) - -## Sponsors - - - - - paradigm logo - - - -
- - - - - family logo - - - - - - context logo - - - - - - WalletConnect logo - - - - - - LooksRare logo - - - - - - PartyDAO logo - - - - - - Dynamic logo - - - - - - Sushi logo - - - - - - Stripe logo - - - - - - BitKeep logo - - - - - - Privy logo - - - - - - Spruce logo - - - - - - rollup.id logo - - - - - - pancake logo - - - - - - celo logo - - - - - - pimlico logo - - - - - - zora logo - - - -## Contributing - -If you're interested in contributing, please read the [contributing docs](/.github/CONTRIBUTING.md) **before submitting a pull request**. - -## Authors - -- [@jxom](https://github.com/jxom) (jxom.eth, [Twitter](https://twitter.com/jakemoxey)) -- [@tmm](https://github.com/tmm) (awkweb.eth, [Twitter](https://twitter.com/awkweb)) - -## License - -[MIT](/LICENSE) License +[EIP-1193](https://eips.ethereum.org/EIPS/eip-1193) wallets use either `eth_signTypedData_v4` (EIP-712) or `eth_sign` (generally regarded as unsafe) to sign confidential requests. We recommend always using EIP-712, which is the default. This default can be overridden by setting `isEIP712` in the request being signed. diff --git a/suave-viem-logo-white.png b/suave-viem-logo-white.png new file mode 100644 index 00000000..3d2271ba Binary files /dev/null and b/suave-viem-logo-white.png differ