@@ -18,8 +18,10 @@ import { ethers6Adapter } from "thirdweb/adapters/ethers6";
18
18
import { sendTransaction } from " thirdweb" ;
19
19
20
20
// convert a ethers signer
21
- const ethersSigner: ethers .Signer = ... ;
22
- const account = await ethers6Adapter .signer .fromEthers (ethersSigner );
21
+ const signer: ethers .Signer = ... ;
22
+ const account = await ethers6Adapter .signer .fromEthers ({
23
+ signer ,
24
+ });
23
25
24
26
// use it with the thirdweb SDK
25
27
await sendTransaction ({
@@ -33,16 +35,22 @@ Similarly, you can use any wallets created with the thirdweb SDK with ethers.js
33
35
``` ts
34
36
import { ethers6Adapter } from " thirdweb/adapters/ethers6" ;
35
37
import { createThirdwebClient , embeddedWallet } from " thirdweb/wallets" ;
38
+ import { sepolia } from " thirdweb/chains" ;
36
39
37
40
const client = createThirdwebClient ({ clientId });
38
41
const wallet = embeddedWallet ();
42
+ const chain = sepolia ;
39
43
const account = await wallet .connect ({
40
44
client ,
41
45
strategy: " google" ,
42
46
});
43
47
44
48
// convert a thirdweb account to ethers signer
45
- const ethersSigner = await ethers6Adapter .signer .toEthers (client , account );
49
+ const ethersSigner = await ethers6Adapter .signer .toEthers ({
50
+ client ,
51
+ chain ,
52
+ account
53
+ });
46
54
```
47
55
48
56
You can also convert ethers.js providers and contracts from and to the thirdweb SDK.
@@ -57,11 +65,17 @@ You can use an existing ethers.js v5 Signer with the thirdweb SDK by converting
57
65
import { ethers5Adapter } from " thirdweb/adapters/ethers5" ;
58
66
59
67
// convert an ethers signer to a thirdweb account
60
- const ethersSigner: ethers .Signer = ... ;
61
- const account = await ethers5Adapter .signer .fromEthers (ethersSigner );
68
+ const signer: ethers .Signer = ... ;
69
+ const account = await ethers5Adapter .signer .fromEthers ({
70
+ signer ,
71
+ });
62
72
63
73
// convert a thirdweb account to ethers signer
64
- const ethersSigner = await ethers6Adapter .signer .toEthers (client , account );
74
+ const ethersSigner = await ethers5Adapter .signer .toEthers ({
75
+ client ,
76
+ chain ,
77
+ account
78
+ });
65
79
```
66
80
67
81
You can also convert ethers.js providers and contracts from and to the thirdweb SDK.
@@ -84,9 +98,9 @@ const account = await viemAdapter.walletClient.fromViem({
84
98
85
99
// convert a thirdweb account to viem wallet client
86
100
const viemClientWallet = viemAdapter .walletClient .toViem ({
87
- client ,
88
- chain ,
89
- account ,
101
+ client ,
102
+ chain ,
103
+ account ,
90
104
});
91
105
```
92
106
0 commit comments