Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Creating New Block for blockchain

Blockchain.prototype.createNewBlock = function(nonce, prevBlockHash, hash){
    const newBlock = {
        index : this.chain.length + 1,
        timestamp : Date.now(),
        transactions : this.pendingTransactions,
        nonce : nonce,
        prevBlockHash : prevBlockHash,
        hash : hash
    };

    this.pendingTransactions = [];
    this.chain.push(newBlock);

    return newBlock;
}
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Creating #New #Block #blockchain
ADD COMMENT
Topic
Name
8+7 =