How a vout (and particularly scriptPubKey) works ?

+2 votes

Hello !

I've some questions about the vout of a transaction, and to be more precise, about scriptPubKey.

As I can see, a typical output transaction looks like this :

{
            "value" : 0.00000000,
            "n" : 1,
            "scriptPubKey" : {
                "asm" : "OP_DUP OP_HASH160 eadb51503d0c15d2d36c3354dd0bfeb63ec4b91b OP_EQUALVERIFY OP_CHECKSIG 73706b67c166070000000000 OP_DROP",
                "hex" : "76a914eadb51503d0c15d2d36c3354dd0bfeb63ec4b91b88ac0c73706b67c16607000000000075",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "1Yk36JuVbQuyr1y5uSJQDLfvnCxpHSi3WNsSgg"
                ]
            },
            "assets" : [
                {
                    "name" : "asset-lot@kjlppp",
                    "issuetxid" : "17b6762b2f5752e224bcd302852d40b68443c04a2bb68d71c473ac4355da30a3",
                    "assetref" : "86-491-46615",
                    "qty" : 485.05700000,
                    "raw" : 485057,
                    "type" : "issuefirst"
                }
            ],
            "permissions" : [
            ],
            "items" : [
            ]
        }

When seeing this, some questions pop out of my mind :

- What is exactly the purpose of scriptPubKey ?

- What is the 'addresses' field in scriptPubKey ? How can it happen to have more than one address on the list ? How the addresses in this field are chosen ?

- Is it possible to clearly identify in a transaction vout to which address an asset (from the assets list) is sent ?

 

Thank you very much for the answers !

asked Jul 5, 2018 by DanielS

1 Answer

+2 votes
 
Best answer

First, please note that a transaction can have multiple outputs in the vout array, not just a single one.

The scriptPubKey represents the conditions under which this output can be spent in the input of a new transaction. In most cases, it just contains a representation of the address owning that output, meaning that it can only be spent by a transaction signed by the private key corresponding to that address.

This is the same address shown in the addresses field. You'll only see multiple addresses there with old style multisignature outputs, which are not really used now, and in that case the assets would be under the collective control of the listed addresses.

answered Jul 5, 2018 by MultiChain
scriptPubKey
...