@@ -82,6 +82,12 @@ private void BuildButtons()
8282 }
8383 } ,
8484 new ButtonStruct
85+ {
86+ Text = "Write Contract" ,
87+ OnClick = OnWriteContractClicked ,
88+ AccountRequired = true
89+ } ,
90+ new ButtonStruct
8591 {
8692 Text = "Disconnect" ,
8793 OnClick = OnDisconnectButton ,
@@ -212,9 +218,14 @@ public async void OnPersonalSignButton()
212218 var account = await Web3Modal . GetAccountAsync ( ) ;
213219
214220 const string message = "Hello from Unity!" ;
221+
222+ Debug . Log ( "Signing message..." ) ;
215223 var signature = await Web3Modal . Evm . SignMessageAsync ( message ) ;
216- var isValid = await Web3Modal . Evm . VerifyMessageSignatureAsync ( account . Address , message , signature ) ;
217224
225+ Debug . Log ( "Verifying signature..." ) ;
226+ var isValid = await Web3Modal . Evm . VerifyMessageSignatureAsync ( account . Address , message , signature ) ;
227+
228+ Debug . Log ( $ "Signature valid: { isValid } ") ;
218229 Notification . ShowMessage ( $ "Signature valid: { isValid } ") ;
219230 }
220231 catch ( RpcResponseException e )
@@ -355,6 +366,32 @@ public async void OnReadContractClicked()
355366 }
356367 }
357368
369+ public async void OnWriteContractClicked ( )
370+ {
371+ const string contractAddress = "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984" ;
372+ const string recipientAddress = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045" ;
373+ const string abi = @"[{""constant"":false,""inputs"":[{""name"":""to"",""type"":""address""},{""name"":""value"",""type"":""uint256""}],""name"":""transfer"",""outputs"":[{""name"":"""",""type"":""bool""}],""payable"":false,""stateMutability"":""nonpayable"",""type"":""function""}]" ;
374+
375+ BigInteger amount = 1 ;
376+
377+ Debug . Log ( "Let's estimate gas..." ) ;
378+
379+ var gas = await Web3Modal . Evm . EstimateGasAsync ( contractAddress , abi , "transfer" , value : default , recipientAddress , amount ) ;
380+
381+ Debug . Log ( $ "Estimated gas: { gas } ") ;
382+
383+
384+
385+ // // Arguments for the transfer method. The order of the arguments must match the order in the method signature.
386+ // // Method signature: `function transfer(address _to, uint256 _value) public returns (bool success)`
387+ // var arguments = new object[]
388+ // {
389+ // recipientAddress,
390+ // amount
391+ // };
392+ // var result = await Web3Modal.Evm.WriteContractAsync(contractAddress, abi, "transfer", arguments);
393+ }
394+
358395 private TypedData < Domain > GetMailTypedDefinition ( )
359396 {
360397 return new TypedData < Domain >
0 commit comments