This invention discloses a method and apparatus for a
virtual machine to read data from an external
system and write data, relating to the field of
computer technology. One specific implementation of the method includes: creating an address buffer within a
smart contract running on the
virtual machine; using the storage address of
external data as an input parameter of the
smart contract; reading
external data from the storage address of the
external data into the address buffer; wherein the storage address is of integer type; enabling the transfer of complex external data types to the
smart contract executed by the Webassembly
virtual machine. Another specific implementation includes: using the data address of the address buffer as an output parameter of the smart contract running on the virtual
machine; passing the data address to an external
system; wherein the output parameter is of integer type; after the external
system creates an external buffer,
copying the data from the data address to the external buffer; enabling the transfer of complex data types from the Webassembly virtual
machine smart contract to the external system.