getStorage

Reads the raw value in smart contract storage.

Input Arguments

ParameterDescription

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

network?: string

Network to submit this request to. If omitted, will default to network the wallet is currently set to

Success Response

ParameterDescription

result: string

The raw value that's stored in the contract

Error Response

ParameterDescription

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

neoline.getStorage({
  scriptHash: '03febccf81ac85e3d795bc5cbd4e84e907812aa3',
  key: 'Peter',
  network: 'TestNet'
})
.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: 'Lin'
}

最后更新于