cosmos / cosmjs

The Swiss Army knife to power JavaScript based client solutions ranging from Web apps/explorers over browser extensions to server-side clients like faucets/scrapers.
https://cosmos.github.io/cosmjs/
Apache License 2.0
645 stars 330 forks source link

Does recieving Transaction result means tx block is mined? #1485

Closed dovigod closed 11 months ago

dovigod commented 11 months ago

I'm currently developing on SEI network which is based on cosmos.

While developing , I found some difference with ethereum, that after sending coin, It gives response like below,

code : 0 events : (10) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}] gasUsed : 81544 gasWanted : 100000 height : 40186186 rawLog : "[{\"events\":[{\"type\":\"coin_received\",\"attributes\":[{\"key\":\"receiver\",\"value\":\"sei1svp0rxm0nwsesmf8ydec5h3g52feqx8lzkksvx\"},{\"key\":\"amount\",\"value\":\"100000usei\"}]},{\"type\":\"coin_spent\",\"attributes\":[{\"key\":\"spender\",\"value\":\"sei1tez8km0fmk72g4urr4jg20p7jv8ulnz056r2a8\"},{\"key\":\"amount\",\"value\":\"100000usei\"}]},{\"type\":\"message\",\"attributes\":[{\"key\":\"action\",\"value\":\"/cosmos.bank.v1beta1.MsgSend\"},{\"key\":\"sender\",\"value\":\"sei1tez8km0fmk72g4urr4jg20p7jv8ulnz056r2a8\"},{\"key\":\"module\",\"value\":\"bank\"}]},{\"type\":\"transfer\",\"attributes\":[{\"key\":\"recipient\",\"value\":\"sei1svp0rxm0nwsesmf8ydec5h3g52feqx8lzkksvx\"},{\"key\":\"sender\",\"value\":\"sei1tez8km0fmk72g4urr4jg20p7jv8ulnz056r2a8\"},{\"key\":\"amount\",\"value\":\"100000usei\"}]}]}]" transactionHash : "98C5D72519DCE30D9853AAC43BA1B98A5899EC6BC07BB166FB51C42E4584D5D4"

I found that property 'height' is the block number which this transaction is in.

Just to induce, since response throws 'block number which tx is held', can I assert that 'transaction response will only returned when transaction is mined?

webmaster128 commented 11 months ago

I don't know exactly what you do and don't know what block number which tx is held is. But in general there are two things to look for: If the transaction result has a height, then it is included in a block. If code == 0, then the transaction was successful. If code != 0, then the transaction was unsuccessful and is reverted.

dovigod commented 11 months ago

@webmaster128 Ah exactly what I was questioning! Thanks! Sorry for the ethereum friendly terms :(