|
340 | 340 |
|
341 | 341 | #endregion |
342 | 342 |
|
343 | | -#region Engine Wallet |
344 | | - |
345 | | -// // EngineWallet is compatible with IThirdwebWallet and can be used with any SDK method/extension |
346 | | -// var engineWallet = await EngineWallet.Create( |
347 | | -// client: client, |
348 | | -// engineUrl: Environment.GetEnvironmentVariable("ENGINE_URL"), |
349 | | -// authToken: Environment.GetEnvironmentVariable("ENGINE_ACCESS_TOKEN"), |
350 | | -// walletAddress: Environment.GetEnvironmentVariable("ENGINE_BACKEND_WALLET_ADDRESS"), |
351 | | -// timeoutSeconds: null, // no timeout |
352 | | -// additionalHeaders: null // can set things like x-account-address if using basic session keys |
353 | | -// ); |
354 | | - |
355 | | -// // Simple self transfer |
356 | | -// var receipt = await engineWallet.Transfer(chainId: 11155111, toAddress: await engineWallet.GetAddress(), weiAmount: 0); |
357 | | -// Console.WriteLine($"Receipt: {receipt}"); |
| 343 | +#region Server Wallet |
| 344 | + |
| 345 | +// You need only pass this if you are using a self-managed vault (check your dashboard Transactions tab) |
| 346 | +var myAccessToken = Environment.GetEnvironmentVariable("VAULT_ACCESS_TOKEN"); |
| 347 | + |
| 348 | +// ServerWallet is compatible with IThirdwebWallet and can be used with any SDK method/extension |
| 349 | +var serverWallet = await ServerWallet.Create( |
| 350 | + client: client, |
| 351 | + label: "Test", |
| 352 | + // Optional, defaults to Auto - we choose between EIP-7702, EIP-4337 or native zkSync AA execution |
| 353 | + executionOptions: new AutoExecutionOptions(), |
| 354 | + vaultAccessToken: myAccessToken |
| 355 | +); |
| 356 | +var serverWalletAddress = await serverWallet.GetAddress(); |
| 357 | +Console.WriteLine($"Server Wallet address: {serverWalletAddress}"); |
| 358 | + |
| 359 | +var serverWalletPersonalSig = await serverWallet.PersonalSign("Hello, Thirdweb!"); |
| 360 | +Console.WriteLine($"Server Wallet personal sign: {serverWalletPersonalSig}"); |
| 361 | + |
| 362 | +var json = |
| 363 | + /*lang=json,strict*/ |
| 364 | + "{\"types\":{\"EIP712Domain\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"version\",\"type\":\"string\"},{\"name\":\"chainId\",\"type\":\"uint256\"},{\"name\":\"verifyingContract\",\"type\":\"address\"}],\"Person\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"wallet\",\"type\":\"address\"}],\"Mail\":[{\"name\":\"from\",\"type\":\"Person\"},{\"name\":\"to\",\"type\":\"Person\"},{\"name\":\"contents\",\"type\":\"string\"}]},\"primaryType\":\"Mail\",\"domain\":{\"name\":\"Ether Mail\",\"version\":\"1\",\"chainId\":84532,\"verifyingContract\":\"0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC\"},\"message\":{\"from\":{\"name\":\"Cow\",\"wallet\":\"0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826\"},\"to\":{\"name\":\"Bob\",\"wallet\":\"0xbBbBBBBbbBBBbbbBbbBbbBBbBbbBbBbBbBbbBBbB\"},\"contents\":\"Hello, Bob!\"}}"; |
| 365 | +var serverWalletTypedDataSign = await serverWallet.SignTypedDataV4(json); |
| 366 | +Console.WriteLine($"Server Wallet typed data sign: {serverWalletTypedDataSign}"); |
| 367 | + |
| 368 | +// ServerWallet forcing ERC-4337 Execution Mode |
| 369 | +var smartServerWallet = await ServerWallet.Create( |
| 370 | + client: client, |
| 371 | + label: "Test", |
| 372 | + executionOptions: new ERC4337ExecutionOptions(chainId: 84532, signerAddress: serverWalletAddress), |
| 373 | + vaultAccessToken: myAccessToken |
| 374 | +); |
| 375 | +var smartServerWalletAddress = await smartServerWallet.GetAddress(); |
| 376 | +Console.WriteLine($"Smart Server Wallet address: {smartServerWalletAddress}"); |
| 377 | + |
| 378 | +var smartServerWalletPersonalSig = await smartServerWallet.PersonalSign("Hello, Thirdweb!"); |
| 379 | +Console.WriteLine($"Smart Server Wallet personal sign: {smartServerWalletPersonalSig}"); |
| 380 | + |
| 381 | +var smartServerWalletTypedDataSign = await smartServerWallet.SignTypedDataV4(json); |
| 382 | +Console.WriteLine($"Smart Server Wallet typed data sign: {smartServerWalletTypedDataSign}"); |
| 383 | + |
| 384 | +// Simple self transfer |
| 385 | +var serverWalletReceipt = await serverWallet.Transfer(chainId: 421614, toAddress: await serverWallet.GetAddress(), weiAmount: 0); |
| 386 | +Console.WriteLine($"Server Wallet Hash: {serverWalletReceipt.TransactionHash}"); |
| 387 | + |
| 388 | +// Simple self transfer |
| 389 | +var smartServerWalletReceipt = await smartServerWallet.Transfer(chainId: 421614, toAddress: await smartServerWallet.GetAddress(), weiAmount: 0); |
| 390 | +Console.WriteLine($"Server Wallet Hash: {smartServerWalletReceipt.TransactionHash}"); |
358 | 391 |
|
359 | 392 | #endregion |
360 | 393 |
|
|
0 commit comments