getStorage

Reads the raw value in smart contract storage.

Input Arguments

Parameter
Description

scriptHash: string

Script hash of the smart contract to invoke a read on

key: string

Key of the storage value to retrieve from the contract

Success Response

Parameter
Description

result: string

The raw value that's stored in the contract

Error Response

Parameter
Description

type: string

The type of error which has occured

description: string

A description of the error which has occured

data: string

Any raw data associated with the error

Example

Request

neolineN3.getStorage({
    scriptHash: '006b26dd0d2aa076b11082847a094772450f05af',
    key: 'token0',
})
.then(result => {
    const value = result;
    console.log('Storage value: ' + value.result);
})
.catch((error) => {
    const {type, description, data} = error;
    switch(type) {
        case 'NO_PROVIDER':
            console.log('No provider available.');
            break;
        case 'CONNECTION_REFUSED':
            console.log('Connection dApp not connected. Please call the "connect" function.');
            break;
        case 'RPC_ERROR':
            console.log('There was an error when broadcasting this transaction to the network.');
            break;
        default:
            // Not an expected error object.  Just write the error to the console.
            console.error(error);
            break;
    }
});

Response

{
    result: 'wYCMqLCTIUiax57E8Zd/O9xN3l8='
}

最后更新于