current position:Home>Store the data on the chain according to the structure format. The read string type data can be returned in the original format, while uint type data is BN type,

Store the data on the chain according to the structure format. The read string type data can be returned in the original format, while uint type data is BN type,

2022-02-03 22:59:18 Q & A of Denglian community

Structure data of smart contract part

struct  CarInfo{        string  name;        string  description;        uint  reward;        uint  waitTime;        uint  longitude;        uint  latitude;    }

Processing logic of data upload

 event NewCarInfo();    function addCarInfo(string memory _name,string memory _description,uint  _reward,  uint  _waitTime,uint  _longitude,uint  _latitude) public {        CarInfo memory carInfo = CarInfo(_name,_description,_reward,_waitTime,_longitude,_latitude);        CarInfos[msg.sender].push(carInfo);        emit NewCarInfo();    }

Access to data console Output

Result0: "4"1: "5"2: BNlength: (...)negative: (...)red: (...)words: (...)__ob__: Observer {value: BN, dep: Dep, vmCount: 0}get length: ƒ reactiveGetter()set length: ƒ reactiveSetter(newVal)get negative: ƒ reactiveGetter()set negative: ƒ reactiveSetter(newVal)get red: ƒ reactiveGetter()set red: ƒ reactiveSetter(newVal)get words: ƒ reactiveGetter()set words: ƒ reactiveSetter(newVal)__proto__: Object





Other answers 1:


Other answers 2:

copyright notice
author[Q & A of Denglian community],Please bring the original link to reprint, thank you.
https://en.netfreeman.com/2022/02/202202032259163410.html

Random recommended