/* Ċ Ġ* ĠCopyright Ġ 2 0 2 0 ĠI ce Rock ĠMAG ĠInc . ĠUse Ġof Ġthis Ġsource Ġcode Ġis Ġgoverned Ġby Ġthe ĠApache Ġ 2 . 0 Ġlicense . Ċ Ġ*/ Ċ Ċ @ file : Suppress (" EXPERIMENT AL _ API _ USAGE ") Ċ Ċ package Ġdev . icer ock . mo ko . web 3 Ċ Ċ import Ġcom . so y wiz . kb ignum . BigInt Ċ import Ġcom . so y wiz . kb ignum . bi Ċ import Ġdev . icer ock . mo ko . web 3 . contract . ABI Encoder Ċ import Ġdev . icer ock . mo ko . web 3 . contract . Address Param Ċ import Ġdev . icer ock . mo ko . web 3 . contract . Smart Contract Ċ import Ġdev . icer ock . mo ko . web 3 . contract . UInt 2 5 6 Param Ċ import Ġdev . icer ock . mo ko . web 3 . contract . create E rc 2 0 Token Ab i Ċ import Ġdev . icer ock . mo ko . web 3 . hex . internal . to Hex Ċ import Ġdev . icer ock . mo ko . web 3 . entity . Rpc Response Ċ import Ġdev . icer ock . mo ko . web 3 . entity . Transaction Receipt Ċ import Ġdev . icer ock . mo ko . web 3 . hex . Hex 3 2 String Ċ import Ġdev . icer ock . mo ko . web 3 . hex . HexString Ċ import Ġdev . icer ock . mo ko . web 3 . requests .* Ċ import Ġdev . icer ock . mo ko . web 3 . requests . polling . new Blocks Short Polling Ċ import Ġdev . icer ock . mo ko . web 3 . requests . polling . new Logs Short Polling Ċ import Ġio . ktor . client . engine . mock . Mock Request Handle Scope Ċ import Ġio . ktor . client . engine . mock . respond Ċ import Ġio . ktor . client . engine . mock . respond BadRequest Ċ import Ġio . ktor . client . request . HttpRequest Data Ċ import Ġio . ktor . client . request . HttpResponse Data Ċ import Ġio . ktor . content . Text Content Ċ import Ġkotlinx . coroutines . flow . collect Ċ import Ġkotlinx . coroutines . run Blocking Ċ import Ġkotlinx . serialization . json . Json Ċ import Ġkotlinx . serialization . json . Json Element Ċ import Ġkotlinx . serialization . json . Json Null Ċ import Ġkotlin . test . Test Ċ import Ġkotlin . test . assertEquals Ċ import Ġkotlin . test . assertTrue Ċ Ċ class ĠWeb 3 Test Ġ{ ĊĠĠĠ Ġprivate Ġval Ġinf ura Url Ġ= Ġ" https :// rin ke by . inf ura . io / v 3 / 5 a 3 d 2 c 3 0 cf 7 2 4 5 0 c 9 e 1 3 b 0 5 7 0 a 7 3 7 b 6 2 " ĊĊĠĠĠ Ġprivate Ġfun Ġcreate Test Web 3 ( ĊĠĠĠĠĠĠĠ Ġhandler : Ġsuspend ĠMock Request Handle Scope .( HttpRequest Data ) Ġ-> ĠHttpResponse Data ĊĠĠĠ Ġ): ĠWeb 3 Ġ= ĠWeb 3 ( ĊĠĠĠĠĠĠĠ ĠhttpClient Ġ= Ġcreate Mock Client ( handler ), ĊĠĠĠĠĠĠĠ Ġendpoint Url Ġ= Ġinf ura Url , ĊĠĠĠĠĠĠĠ Ġjson Ġ= ĠJson ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` read Ġtransaction `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġweb 3 Ġ= Ġcreate Test Web 3 Ġ{ Ġrequest Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġbody Ġ= Ġrequest . body ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( body Ġis ĠText Content ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Ġ= Ġ""" [{" jsonrpc ":" 2 . 0 "," id ": 0 ," method ":" eth _ getTransaction By Hash "," params ":[" 0 x 6 2 7 9 1 4 c 8 d 0 0 5 ab 0 dc 7 f 4 4 7 1 9 dc 6 5 8 af 7 2 e 5 3 4 e 0 8 3 8 6 7 a 2 a 3 1 6 d 4 b 2 5 5 5 5 5 1 5 3 5 2 "] }] """, ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġactual Ġ= Ġbody . text ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġrespond ( content Ġ= Ġ""" [{" jsonrpc ":" 2 . 0 "," id ": 0 ," result ":{" block Hash ":" 0 x 3 d 6 2 f 8 6 2 d 2 5 cf 7 0 1 5 a 4 8 5 8 6 8 b 0 7 8 2 5 4 8 4 fd 7 a 5 1 f 7 7 a 9 e 7 8 6 3 fe 4 5 ec 8 a 6 1 db 0 1 b "," block Number ":" 0 x 6 0 f 0 3 b "," from ":" 0 xde 7 ec 4 e 4 8 9 5 d 7 d 1 4 8 9 0 6 a 0 dfa af 7 f 2 1 ac 5 c 5 b 8 0 c "," gas ":" 0 x 4 e 9 e 4 "," gas Price ":" 0 x 1 dcd 6 5 0 0 0 "," hash ":" 0 x 6 2 7 9 1 4 c 8 d 0 0 5 ab 0 dc 7 f 4 4 7 1 9 dc 6 5 8 af 7 2 e 5 3 4 e 0 8 3 8 6 7 a 2 a 3 1 6 d 4 b 2 5 5 5 5 5 1 5 3 5 2 "," input ":" 0 x 8 5 2 a 1 2 e 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 7 0 de 4 df 8 2 0 0 0 0 "," nonce ":" 0 x 4 a "," r ":" 0 x 5 a eca 7 a 5 4 ae 3 bb 0 f 6 7 a 2 9 ae ce 0 0 d 7 1 bc 7 5 c 0 d 0 6 b 8 9 9 5 0 ea 6 0 0 a 0 b 3 b 6 bb fe 5 e 8 c "," s ":" 0 x 6 8 fe fa 5 3 3 3 e 9 4 4 4 3 dca 1 9 e 3 0 5 6 2 bf 2 9 7 b 8 a 6 8 7 abf 1 5 c 3 fe 2 6 7 1 de 6 2 3 3 2 9 9 fff 0 "," to ":" 0 xd 6 8 0 1 a 1 dff cd 0 a 4 1 0 3 3 6 ef 8 8 def 4 3 2 0 d 6 df 1 8 8 3 e "," transaction Index ":" 0 x 1 "," type ":" 0 x 0 "," v ":" 0 x 2 c "," value ":" 0 x 0 "}} ] """) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġval Ġtx Hash Ġ= ĠTransaction Hash (" 0 x 6 2 7 9 1 4 c 8 d 0 0 5 ab 0 dc 7 f 4 4 7 1 9 dc 6 5 8 af 7 2 e 5 3 4 e 0 8 3 8 6 7 a 2 a 3 1 6 d 4 b 2 5 5 5 5 5 1 5 3 5 2 ") ĊĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġrun Test Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġweb 3 . getTransaction ( tx Hash ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( actual Ġ= Ġresult . tx Hash , Ġexpected Ġ= Ġtx Hash ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( actual Ġ= Ġresult . gas Price , Ġexpected Ġ= ĠBigInt ( 8 0 0 0 0 0 0 0 0 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( actual Ġ= Ġresult . gas Limit , Ġexpected Ġ= ĠBigInt ( 3 2 2 0 2 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( actual Ġ= Ġresult . transaction Index , Ġexpected Ġ= ĠBigInt ( 1 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( actual Ġ= Ġresult . nonce , Ġexpected Ġ= ĠBigInt ( 7 4 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġactual Ġ= Ġresult . block Hash , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Ġ= ĠBlock Hash (" 0 x 3 d 6 2 f 8 6 2 d 2 5 cf 7 0 1 5 a 4 8 5 8 6 8 b 0 7 8 2 5 4 8 4 fd 7 a 5 1 f 7 7 a 9 e 7 8 6 3 fe 4 5 ec 8 a 6 1 db 0 1 b ") ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġactual Ġ= Ġresult . block Number , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Ġ= ĠBigInt ( 6 3 5 2 9 5 5 ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġactual Ġ= Ġresult . sender Address , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Ġ= ĠWallet Address (" 0 xde 7 ec 4 e 4 8 9 5 d 7 d 1 4 8 9 0 6 a 0 dfa af 7 f 2 1 ac 5 c 5 b 8 0 c ") ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġactual Ġ= Ġresult . receiver Address , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Ġ= ĠWallet Address (" 0 xd 6 8 0 1 a 1 dff cd 0 a 4 1 0 3 3 6 ef 8 8 def 4 3 2 0 d 6 df 1 8 8 3 e ") ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġactual Ġ= Ġresult . input , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Ġ= Ġ" 0 x 8 5 2 a 1 2 e 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 7 0 de 4 df 8 2 0 0 0 0 " ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` read Ġtransaction Ġreceipt `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġweb 3 Ġ= Ġcreate Test Web 3 Ġ{ Ġrequest Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġbody Ġ= Ġrequest . body ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( body Ġis ĠText Content ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Ġ= Ġ""" [{" jsonrpc ":" 2 . 0 "," id ": 0 ," method ":" eth _ getTransaction Receipt "," params ":[" 0 x 6 2 7 9 1 4 c 8 d 0 0 5 ab 0 dc 7 f 4 4 7 1 9 dc 6 5 8 af 7 2 e 5 3 4 e 0 8 3 8 6 7 a 2 a 3 1 6 d 4 b 2 5 5 5 5 5 1 5 3 5 2 "] }] """, ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġactual Ġ= Ġbody . text ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġrespond ( content Ġ= Ġ""" [{" jsonrpc ":" 2 . 0 "," id ": 0 ," result ":{" block Hash ":" 0 x 3 d 6 2 f 8 6 2 d 2 5 cf 7 0 1 5 a 4 8 5 8 6 8 b 0 7 8 2 5 4 8 4 fd 7 a 5 1 f 7 7 a 9 e 7 8 6 3 fe 4 5 ec 8 a 6 1 db 0 1 b "," block Number ":" 0 x 6 0 f 0 3 b "," contract Address ": null ," cumulative Gas Used ":" 0 x 3 ae 8 d "," effective Gas Price ":" 0 x 1 dcd 6 5 0 0 0 "," from ":" 0 xde 7 ec 4 e 4 8 9 5 d 7 d 1 4 8 9 0 6 a 0 dfa af 7 f 2 1 ac 5 c 5 b 8 0 c "," gas Used ":" 0 x 3 4 7 2 5 "," logs ":[{" address ":" 0 xd 6 8 0 1 a 1 dff cd 0 a 4 1 0 3 3 6 ef 8 8 def 4 3 2 0 d 6 df 1 8 8 3 e "," block Hash ":" 0 x 3 d 6 2 f 8 6 2 d 2 5 cf 7 0 1 5 a 4 8 5 8 6 8 b 0 7 8 2 5 4 8 4 fd 7 a 5 1 f 7 7 a 9 e 7 8 6 3 fe 4 5 ec 8 a 6 1 db 0 1 b "," block Number ":" 0 x 6 0 f 0 3 b "," data ":" 0 x 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 8 a 9 f 2 e 7 2 4 2 1 c 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 3 9 3 8 f 9 5 c 5 bb 8 de 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 e 6 f 3 9 5 eb 6 3 9 5 7 7 b 1 2 "," log Index ":" 0 x 0 "," removed ": false ," topics ":[" 0 x 8 7 5 3 5 2 fb 3 fade b 8 c 0 be 7 cb be 8 ff 7 6 1 b 3 0 8 fa 7 0 3 3 4 7 0 cd 0 2 8 7 f 0 2 f 3 4 3 6 fd 7 6 cb 9 "]," transaction Hash ":" 0 x 6 2 7 9 1 4 c 8 d 0 0 5 ab 0 dc 7 f 4 4 7 1 9 dc 6 5 8 af 7 2 e 5 3 4 e 0 8 3 8 6 7 a 2 a 3 1 6 d 4 b 2 5 5 5 5 5 1 5 3 5 2 "," transaction Index ":" 0 x 1 "},{" address ":" 0 xd 6 8 0 1 a 1 dff cd 0 a 4 1 0 3 3 6 ef 8 8 def 4 3 2 0 d 6 df 1 8 8 3 e "," block Hash ":" 0 x 3 d 6 2 f 8 6 2 d 2 5 cf 7 0 1 5 a 4 8 5 8 6 8 b 0 7 8 2 5 4 8 4 fd 7 a 5 1 f 7 7 a 9 e 7 8 6 3 fe 4 5 ec 8 a 6 1 db 0 1 b "," block Number ":" 0 x 6 0 f 0 3 b "," data ":" 0 x 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 2 f 2 dd 9 "," log Index ":" 0 x 1 "," removed ": false ," topics ":[" 0 xdd f 2 5 2 ad 1 be 2 c 8 9 b 6 9 c 2 b 0 6 8 fc 3 7 8 daa 9 5 2 ba 7 f 1 6 3 c 4 a 1 1 6 2 8 f 5 5 a 4 df 5 2 3 b 3 ef "," 0 x 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 de 7 ec 4 e 4 8 9 5 d 7 d 1 4 8 9 0 6 a 0 dfa af 7 f 2 1 ac 5 c 5 b 8 0 c "," 0 x 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 d 6 8 0 1 a 1 dff cd 0 a 4 1 0 3 3 6 ef 8 8 def 4 3 2 0 d 6 df 1 8 8 3 e "]," transaction Hash ":" 0 x 6 2 7 9 1 4 c 8 d 0 0 5 ab 0 dc 7 f 4 4 7 1 9 dc 6 5 8 af 7 2 e 5 3 4 e 0 8 3 8 6 7 a 2 a 3 1 6 d 4 b 2 5 5 5 5 5 1 5 3 5 2 "," transaction Index ":" 0 x 1 "},{" address ":" 0 xd 6 8 0 1 a 1 dff cd 0 a 4 1 0 3 3 6 ef 8 8 def 4 3 2 0 d 6 df 1 8 8 3 e "," block Hash ":" 0 x 3 d 6 2 f 8 6 2 d 2 5 cf 7 0 1 5 a 4 8 5 8 6 8 b 0 7 8 2 5 4 8 4 fd 7 a 5 1 f 7 7 a 9 e 7 8 6 3 fe 4 5 ec 8 a 6 1 db 0 1 b "," block Number ":" 0 x 6 0 f 0 3 b "," data ":" 0 x 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 de 7 ec 4 e 4 8 9 5 d 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 2 e 5 3 4 e 0 8 3 8 6 7 a 2 a 3 1 6 d 4 b 2 5 5 5 5 5 1 5 3 5 2 ") ĊĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġrun Test Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġweb 3 . getTransaction Receipt ( tx Hash ) Ġ?: Ġerror (" This Ġtransaction Ġshould Ġexist ") ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( actual Ġ= Ġresult . tx Hash , Ġexpected Ġ= Ġtx Hash ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( actual Ġ= Ġresult . contract Address , Ġexpected Ġ= Ġnull ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( actual Ġ= Ġresult . cumulative Gas Used , Ġexpected Ġ= ĠBigInt ( 2 4 1 2 9 3 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( actual Ġ= Ġresult . gas Used , Ġexpected Ġ= ĠBigInt ( 2 1 4 8 2 1 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( actual Ġ= Ġresult . transaction Index , Ġexpected Ġ= ĠBigInt ( 1 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( actual Ġ= Ġresult . status , Ġexpected Ġ= ĠTransaction Receipt . Status . SUCCESS ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( actual Ġ= Ġresult . block Number , Ġexpected Ġ= ĠBigInt ( 6 3 5 2 9 5 5 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġactual Ġ= Ġresult . block Hash , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Ġ= ĠBlock Hash (" 0 x 3 d 6 2 f 8 6 2 d 2 5 cf 7 0 1 5 a 4 8 5 8 6 8 b 0 7 8 2 5 4 8 4 fd 7 a 5 1 f 7 7 a 9 e 7 8 6 3 fe 4 5 ec 8 a 6 1 db 0 1 b ") ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġactual Ġ= Ġresult . sender Address , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Ġ= ĠWallet Address (" 0 xde 7 ec 4 e 4 8 9 5 d 7 d 1 4 8 9 0 6 a 0 dfa af 7 f 2 1 ac 5 c 5 b 8 0 c ") ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġactual Ġ= Ġresult . receiver Address , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Ġ= ĠWallet Address (" 0 xd 6 8 0 1 a 1 dff cd 0 a 4 1 0 3 3 6 ef 8 8 def 4 3 2 0 d 6 df 1 8 8 3 e ") ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġresult . logs . forEach Ġ{ Ġevent Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġactual Ġ= Ġevent . block Hash , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Ġ= ĠBlock Hash (" 0 x 3 d 6 2 f 8 6 2 d 2 5 cf 7 0 1 5 a 4 8 5 8 6 8 b 0 7 8 2 5 4 8 4 fd 7 a 5 1 f 7 7 a 9 e 7 8 6 3 fe 4 5 ec 8 a 6 1 db 0 1 b ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( actual Ġ= Ġevent . transaction Hash , Ġexpected Ġ= Ġtx Hash ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( actual Ġ= Ġevent . block Number , Ġexpected Ġ= ĠBigInt ( 6 3 5 2 9 5 5 )) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( actual Ġ= Ġresult . transaction Index , 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ĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġactual Ġ= Ġresult . logs [ 2 ]. topics , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Ġ= ĠlistOf ( Hex 3 2 String (" 0 xe 5 b 7 5 4 fb 1 abb 7 f 0 1 b 4 9 9 7 9 1 d 0 b 8 2 0 ae 3 b 6 af 3 4 2 4 ac 1 c 5 9 7 6 8 edb 5 3 f 4 ec 3 1 a 9 2 9 ")) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` smart Ġcontract Ġparams `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġjson Ġ= ĠJson ĊĠĠĠĠĠĠĠ Ġval Ġexecutor Ġ= Ġcreate Test Web 3 Ġ{ Ġrespond BadRequest () Ġ} ĊĠĠĠĠĠĠĠ Ġval Ġsmart Contract Ġ= ĠSmart Contract ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġexecutor Ġ= Ġexecutor , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontract Address Ġ= ĠContract Address (" 0 x 6 b 1 7 5 4 7 4 e 8 9 0 9 4 c 4 4 da 9 8 b 9 5 4 ee de ac 4 9 5 2 7 1 d 0 f "), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġabi Json Ġ= Ġcreate E rc 2 0 Token Ab i ( json ) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġaddr Ġ= Ġ" 9 a 0 A 2 4 9 8 Ec 7 f 1 0 5 ef 6 5 5 8 6 5 9 2 a 5 B 6 d 4 Da 3 5 9 0 D 7 4 ". bi ( 1 6 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġrun Test Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠABI Encoder . encode Call Data For Method ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġabi Ġ= Ġcreate E rc 2 0 Token Ab i ( json ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmethod Ġ= Ġ" transfer ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġparams Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġaddr , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠBigInt ( 0 x 1 0 0 0 1 0 0 0 ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Ġ= Ġ" 0 xa 9 0 5 9 cbb 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 a 0 a 2 4 9 8 ec 7 f 1 0 5 ef 6 5 5 8 6 5 9 2 a 5 b 6 d 4 da 3 5 9 0 d 7 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 ". let (:: HexString ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġactual Ġ= Ġresult ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` address Ġencoder `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġparam Ġ= ĠAddress Param ĊĠĠĠĠĠĠĠ Ġval Ġaddr Ġ= Ġ" 9 a 0 A 2 4 9 8 Ec 7 f 1 0 5 ef 6 5 5 8 6 5 9 2 a 5 B 6 d 4 Da 3 5 9 0 D 7 4 ". bi ( 1 6 ) ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġparam . encode ( addr ) ĊĠĠĠĠĠĠĠ Ġval Ġhex Ġ= Ġresult . to Hex () ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Ġ= Ġ" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 a 0 a 2 4 9 8 ec 7 f 1 0 5 ef 6 5 5 8 6 5 9 2 a 5 b 6 d 4 da 3 5 9 0 d 7 4 ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġactual Ġ= Ġhex . lowercase () ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġaddress Ġ= Ġparam . decode ( result ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Ġ= Ġaddr , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġactual Ġ= Ġaddress ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` unit 2 5 6 Ġencoder `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġparam Ġ= ĠUInt 2 5 6 Param ĊĠĠĠĠĠĠĠ Ġval Ġinput Ġ= Ġ" 1 2 3 4 5 6 7 8 9 1 0 1 1 ad fdf dead fea 1 2 3 d 3 4 cd 3 4 2 dcd 2 3 4 2 3 4 ff eed d 3 4 2 4 3 2 dd ff 5 5 5 ". bi ( 1 6 ) ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġparam . encode ( input ) ĊĠĠĠĠĠĠĠ Ġval Ġhex Ġ= Ġresult . to Hex () ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Ġ= Ġ" 1 2 3 4 5 6 7 8 9 1 0 1 1 ad fdf dead fea 1 2 3 d 3 4 cd 3 4 2 dcd 2 3 4 2 3 4 ff eed d 3 4 2 4 3 2 dd ff 5 5 5 ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġactual Ġ= Ġhex . lowercase () ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġoutput Ġ= Ġparam . decode ( result ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Ġ= Ġinput , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġactual Ġ= Ġoutput ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` smart Ġcontract Ġencoding `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġjson Ġ= ĠJson ĊĠĠĠĠĠĠĠ Ġval Ġexecutor Ġ= Ġcreate Test Web 3 Ġ{ Ġrespond BadRequest () Ġ} ĊĠĠĠĠĠĠĠ Ġval Ġsmart Contract Ġ= ĠSmart Contract ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġexecutor Ġ= Ġexecutor , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontract Address Ġ= ĠContract Address ( value Ġ= Ġ" 0 x 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 "), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġabi Json Ġ= Ġcreate Test Ab i ( json ) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġaddress Ġ= Ġ" 9 a 0 A 2 4 9 8 Ec 7 f 1 0 5 ef 6 5 5 8 6 5 9 2 a 5 B 6 d 4 Da 3 5 9 0 D 7 4 ". bi ( 1 6 ) ĊĠĠĠĠĠĠĠ Ġval Ġbig Int Ġ= Ġ" 1 6 3 4 5 7 8 5 d 8 a 0 0 0 0 ". bi ( 1 6 ) ĊĠĠĠĠĠĠĠ Ġval Ġlist Ġ= ĠlistOf ( address , Ġbig Int ) ĊĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġrun Test Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠABI Encoder . encode Call Data For Method ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġabi Ġ= Ġcreate Test Ab i ( json ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmethod Ġ= Ġ" test ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġparams Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġaddress , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġbig Int , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġlist , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġaddress , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġlist ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Ġ= Ġ" 0 x 1 7 0 1 5 9 cd 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 a 0 a 2 4 9 8 ec 7 f 1 0 5 ef 6 5 5 8 6 5 9 2 a 5 b 6 d 4 da 3 5 9 0 d 7 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 a 0 a 2 4 9 8 ec 7 f 1 0 5 ef 6 5 5 8 6 5 9 2 a 5 b 6 d 4 da 3 5 9 0 d 7 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 6 3 4 5 7 8 5 d 8 a 0 0 0 0 ". let (:: HexString ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġactual Ġ= Ġresult ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` read Ġbalance `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġweb 3 Ġ= Ġcreate Test Web 3 Ġ{ Ġrequest Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġbody Ġ= Ġrequest . body ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( body Ġis ĠText Content ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Ġ= Ġ""" [{" jsonrpc ":" 2 . 0 "," id ": 0 ," method ":" eth _ get Balance "," params ":[" 0 xd E 7 e C 4 E 4 8 9 5 D 7 d 1 4 8 9 0 6 a 0 DF a AF 7 f 2 1 ac 5 C 5 B 8 0 C "," latest "] }] """, ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġactual Ġ= Ġbody . text ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġrespond ( content Ġ= Ġ""" [{" jsonrpc ":" 2 . 0 "," id ": 0 ," result ":" 0 xd 9 4 ec 0 6 0 b 1 4 7 7 3 c 7 "}] """) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġrun Test Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġweb 3 . get Native Balance ( Wallet Address (" 0 xd E 7 e C 4 E 4 8 9 5 D 7 d 1 4 8 9 0 6 a 0 DF a AF 7 f 2 1 ac 5 C 5 B 8 0 C ")) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Ġ= Ġ" 1 5 6 5 8 6 6 4 4 7 5 9 3 7 4 3 6 6 1 5 ". bi , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġactual Ġ= Ġresult ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` get Ġnonce `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġweb 3 Ġ= Ġcreate Test Web 3 Ġ{ Ġrequest Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġbody Ġ= Ġrequest . body ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( body Ġis ĠText Content ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Ġ= Ġ""" [{" jsonrpc ":" 2 . 0 "," id ": 0 ," method ":" eth _ getTransaction Count "," params ":[" 0 xd E 7 e C 4 E 4 8 9 5 D 7 d 1 4 8 9 0 6 a 0 DF a AF 7 f 2 1 ac 5 C 5 B 8 0 C "," pending "] }] """, ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġactual Ġ= Ġbody . text ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġrespond ( content Ġ= Ġ""" [{" jsonrpc ":" 2 . 0 "," id ": 0 ," result ":" 0 x 1 2 7 5 "}] """) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġrun Test Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġweb 3 . get Native Transaction Count ( Wallet Address (" 0 xd E 7 e C 4 E 4 8 9 5 D 7 d 1 4 8 9 0 6 a 0 DF a AF 7 f 2 1 ac 5 C 5 B 8 0 C ")) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Ġ= Ġ 4 7 2 5 . bi , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġactual Ġ= Ġresult ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` batch Ġtest `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġweb 3 Ġ= Ġcreate Test Web 3 Ġ{ Ġrequest Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġbody Ġ= Ġrequest . body ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( body Ġis ĠText Content ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Ġ= Ġ""" [{" jsonrpc ":" 2 . 0 "," id ": 0 ," method ":" eth _ getTransaction Count "," params ":[" 0 xd E 7 e C 4 E 4 8 9 5 D 7 d 1 4 8 9 0 6 a 0 DF a AF 7 f 2 1 ac 5 C 5 B 8 0 C "," pending "] },{" jsonrpc ":" 2 . 0 "," id ": 1 ," method ":" eth _ get Balance "," params ":[" 0 xd E 7 e C 4 E 4 8 9 5 D 7 d 1 4 8 9 0 6 a 0 DF a AF 7 f 2 1 ac 5 C 5 B 8 0 C "," latest "] }] """, ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġactual Ġ= Ġbody . text ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġrespond ( content Ġ= Ġ""" [{" jsonrpc ":" 2 . 0 "," id ": 0 ," result ":" 0 x 1 2 7 5 "},{" jsonrpc ":" 2 . 0 "," id ": 1 ," result ":" 0 xd 9 4 ec 0 6 0 b 1 4 7 7 3 c 7 "}] """) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġwallet Ġ= ĠWallet Address (" 0 xd E 7 e C 4 E 4 8 9 5 D 7 d 1 4 8 9 0 6 a 0 DF a AF 7 f 2 1 ac 5 C 5 B 8 0 C ") ĊĊĠĠĠĠĠĠĠ Ġval Ġ( nonce , Ġbalance ) Ġ= Ġrun Test Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġweb 3 . execute Batch ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠWeb 3 Requests . get Native Transaction Count ( wallet ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠWeb 3 Requests . get Native Balance ( wallet ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Ġ= Ġ 4 7 2 5 . bi , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġactual Ġ= Ġnonce ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Ġ= Ġ" 1 5 6 5 8 6 6 4 4 7 5 9 3 7 4 3 6 6 1 5 ". bi , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġactual Ġ= Ġbalance ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` gas Ġprice Ġtest `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġweb 3 Ġ= Ġcreate Test Web 3 Ġ{ Ġrequest Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġbody Ġ= Ġrequest . body ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( body Ġis ĠText Content ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Ġ= Ġ""" [{" jsonrpc ":" 2 . 0 "," id ": 0 ," method ":" eth _ gas Price "," params ": [] }] """, ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġactual Ġ= Ġbody . text ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġrespond ( content Ġ= Ġ""" [{" jsonrpc ":" 2 . 0 "," id ": 0 ," result ":" 0 x 3 b 9 aca 0 8 "}] """) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġrun Test Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Ġ= Ġ 1 0 0 0 0 0 0 0 0 8 . bi , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġactual Ġ= Ġweb 3 . get Gas Price () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ Ċ // ĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` short Ġpolling Ġtest `() Ġ{ ĊĠĠĠĠĠĠĠ Ġrun Test Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġprintln ( Json . decode FromString ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠRpc Response . serializer ( Json Element . serializer ()), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ""" {" jsonrpc ":""," id ": 0 ," result ": null } "" "). result Ġas ĠJson Null ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġweb 3 Ġ= ĠWeb 3 (" https :// rin ke by . inf ura . io / v 3 / 5 a 3 d 2 c 3 0 cf 7 2 4 5 0 c 9 e 1 3 b 0 5 7 0 a 7 3 7 b 6 2 ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġweb 3 . waitFor Transaction Receipt ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠTransaction Hash (" 0 x 6 f 7 9 1 4 c 8 d 0 0 5 ab 0 dc 7 f 4 4 7 1 9 dc 6 5 8 af 7 2 e 5 3 4 e 0 8 3 8 6 7 a 2 a 3 1 6 d 4 b 2 5 5 5 5 5 1 5 3 5 2 "), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġtime Out Millis Ġ= Ġ 5 _ 0 0 0 ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ Ċ // ĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` new Ġblocks Ġshort Ġpolling Ġtest `() Ġ{ ĊĠĠĠĠĠĠĠ Ġrun Blocking Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġweb 3 Ġ= ĠWeb 3 (" https :// rin ke by . inf ura . io / v 3 / 5 a 3 d 2 c 3 0 cf 7 2 4 5 0 c 9 e 1 3 b 0 5 7 0 a 7 3 7 b 6 2 ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġweb 3 . new Blocks Short Polling ( polling Interval Ġ= Ġ 5 _ 0 0 0 ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. collect Ġ{ Ġprintln (" Block Ġ${ it . hash } Ġm ined !") Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ Ċ // ĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` new Ġlogs Ġshort Ġpolling Ġtest `() Ġ{ ĊĠĠĠĠĠĠĠ Ġrun Blocking Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġweb 3 Ġ= ĠWeb 3 (" https :// rin ke by . inf ura . io / v 3 / 5 a 3 d 2 c 3 0 cf 7 2 4 5 0 c 9 e 1 3 b 0 5 7 0 a 7 3 7 b 6 2 ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġweb 3 . new Logs Short Polling ( polling Interval Ġ= Ġ 5 _ 0 0 0 ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. collect Ġ{ Ġprintln (" Log Ġ$ it Ġcaught !") Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ Ċ // ĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġlegacy Transaction Form ing () Ġ{ ĊĠĠĠĠĠĠĠ Ġrun Blocking Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġweb 3 Ġ= ĠWeb 3 (" https :// api . avax - test . network / ext / bc / C / rpc ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġprice Ġ= Ġweb 3 . get Gas Price () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġprintln (" G AS ĠPrice : Ġ$ price ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġprintln (" G AS ĠLimit : Ġ${ web 3 . get Estimate Gas ( price )} ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ