blockcore-indexer icon indicating copy to clipboard operation
blockcore-indexer copied to clipboard

Add support for OP_SPEND and OP_INTERNALCONTRACTTRANSFER

Open dangershony opened this issue 2 years ago • 2 comments

ah interesting, I could fetch the gas cost but I need to know where to look for it In the deserialized create/call transaction params you can get the gas price and gas limit

Funds transferred to contract It's the amount of the output with the OP_CREATE or OP_CALL opcode in the scriptpubkey

balance of the contract The account state keeps track of current contract balances. There's an API call on the smart contracts controller that you can look at for an example. Each contract with a balance has a single unspent output stored in the account state. When a contract spends funds it uses a special opcode in the input scriptpubkey OP_SPEND.

Funds transferred from a contract Contracts spending funds use an input with the scriptpubkey beginning with OP_SPEND (important to note: so do gas refunds)

Gas refunds Input's scriptpubkey begins with OP_SPEND and they are all in the last transaction in the block (condensing transaction)

Funds transferred between contracts Output's scriptpubkey begins with OP_INTERNALCONTRACTTRANSFER + the contract address who can spend the output.

dangershony avatar Jan 25 '22 13:01 dangershony