Storage

The Storage library allows a contract to interact with contract storage and also the decentralized file storage of Phantasma.

MethodReturn typeDescription

Storage.read(contract:String, field:String)

Generic

Reads a field from a contract.

Storage.write(field:String, value:Any)

None

Writes a field value. Due to security reasons, it's not possible to specify a contract, instead the current contract is used. If the current context is not a valid contract or is a read-only context, this method will fail.

Storage.delete(field:String)

None

Deletes a field. Same rules as Storage.write()

Storage.calculateStorageSizeForStake(stakeAmount:Number)

Number

Converts amount of staked SOUL into kilobytes of storage.

Storage.createFile(target:Address, fileName:String, fileSize:Number, contentMerkle:Bytes, encryptionContent:Bytes)

None

Creates a new decentralized file in the target address account. Note that since in Phantasma the actual file contents are not stored in the chain, only a content merkle should be provided.

Storage.hasFile(target:Address, hash:Hash)

Bool

Returns true if the target is storing a file with the specified hash, false otherwise.

Storage.addFile(from:Address, target:Address, archiveHash:Hash)

None

Copies a file with the specified hash into the target address storage.

Storage.deleteFile(from:Address, targetHash:Hash)

None

Deletes the file with the specified hash from the specified address storage.

Storage.hasPermission(externalAddr:Address, target:Address)

Bool

Returns true if external address has permission to add files to target address, false otherwise.

Storage.addPermission(from:Address, externalAddr:Address)

None

Adds permission to external address to add files to from address storage.

Storage.deletePermission(from:Address, externalAddr:Address)

None

Removes permission from external address to add files to from address storage.

Storage.getUsedSpace(from:Address)

Number

Returns how many kilobytes are being used as storage by the specified address.

Storage.getAvailableSpace(from:Address)

Number

Returns how many kilobytes are being available as storage by the specified address.

Last updated