Ocean Assets Tech Details
Technical details about OceanAssets functions
Through this class we can publish different types of assets & consume them to make 💲💲💲
Creates URL Asset
create_url_asset(
self
,name: str
,url: str
,publisher_wallet
,wait_for_aqua: bool = True
) ->tuple
It is the most used functions in all the READMEs.
Creates asset of type "dataset", having UrlFiles
, with good defaults.
It can be called after instantiating Ocean object.
Parameters
name
- name of the asset,string
url
- url that is stored in the asset,string
publisher_wallet
- wallet of the asset publisher/owner,eth Account
wait_for_aqua
- boolean value which default isTrue
, waiting for aquarius to fetch the asset takes additional time, but if you want to be sure that your asset is indexed, keep the default value.
Returns
tuple
A tuple which contains the data NFT, datatoken and the data asset.
Defined in
Creates Algorithm Asset
create_algo_asset(
self
,name: str
,url: str
,publisher_wallet
,image: str = "oceanprotocol/algo_dockers"
,tag: str = "python-branin"
,checksum: str = "sha256:8221d20c1c16491d7d56b9657ea09082c0ee4a8ab1a6621fa720da58b09580e4"
,wait_for_aqua: bool = True
) ->tuple
:
Create asset of type "algorithm", having UrlFiles
, with good defaults.
It can be called after instantiating Ocean object.
Parameters:
name
- name of the asset,string
url
- url that is stored in the asset,string
publisher_wallet
- wallet of the asset publisher/owner,eth Account
image
- docker image of that algorithm,string
tag
- docker tag for that algorithm image,string
checksum
- docker checksum for algorithm's image,string
wait_for_aqua
- boolean value which default isTrue
, waiting for aquarius to fetch the asset takes additional time, but if you want to be sure that your asset is indexed, keep the default value.
Returns
tuple
A tuple which contains the algorithm NFT, algorithm datatoken and the algorithm asset.
Defined in
Creates Arweave Asset
create_arweave_asset(
self
,name: str
,transaction_id: str
,publisher_wallet
,wait_for_aqua: bool = True
) ->tuple
Creates asset of type "data", having ArweaveFile
, with good defaults.
It can be called after instantiating Ocean object.
Parameters
name
- name of the asset,string
transaction_id
- transaction id from the arweave file,string
publisher_wallet
- wallet of the asset publisher/owner,eth Account
wait_for_aqua
- boolean value which default isTrue
, waiting for aquarius to fetch the asset takes additional time, but if you want to be sure that your asset is indexed, keep the default value.
Returns
tuple
A tuple which contains the data NFT, datatoken and the data asset.
Defined in
Creates GraphQL Asset
create_graphql_asset(
self
,name: str
,url: str
,query: str
,publisher_wallet
,wait_for_aqua: bool = True
) ->tuple
Creates asset of type "data", having GraphqlQuery
files, with good defaults.
It can be called after instantiating Ocean object.
Parameters
name
- name of the asset,string
url
- url of subgraph that you are using,string
query
- GraphQL query,string
publisher_wallet
- wallet of the asset publisher/owner,eth Account
wait_for_aqua
- boolean value which default isTrue
, waiting for aquarius to fetch the asset takes additional time, but if you want to be sure that your asset is indexed, keep the default value.
Returns
tuple
A tuple which contains the data NFT, datatoken and the data asset.
Defined in
Creates Onchain Asset
create_onchain_asset(
self
,name: str
,contract_address: str
,contract_abi: dict
,publisher_wallet
,wait_for_aqua: bool = True
) ->tuple
Creates asset of type "data", having SmartContractCall
files, with good defaults.
It can be called after instantiating Ocean object.
Parameters
name
- name of the asset,string
contract_address
- contract address that should be stored in the asset,string
contract_abi
- ABI of functions presented in the contract,string
publisher_wallet
- wallet of the asset publisher/owner,eth Account
wait_for_aqua
- boolean value which default isTrue
, waiting for aquarius to fetch the asset takes additional time, but if you want to be sure that your asset is indexed, keep the default value.
Returns
tuple
A tuple which contains the data NFT, datatoken and the data asset.
Defined in
Creates Asset (for advanced skills)
create(
self
,metadata: dict
,publisher_wallet
,credentials: Optional[dict] = None
,data_nft_address: Optional[str] = None
,data_nft_args: Optional[DataNFTArguments] = None
,deployed_datatokens: Optional[List[Datatoken]] = None
,services: Optional[list] = None
,datatoken_args: Optional[List["DatatokenArguments"]] = None
,encrypt_flag: Optional[bool] = True
,compress_flag: Optional[bool] = True
,wait_for_aqua: bool = True
) ->tuple
Register an asset on-chain. Asset = {data_NFT, >=0 datatokens, DDO}
Creating/deploying a DataNFT contract and in the Metadata store (Aquarius).
Parameters
metadata
:dictionary
conforming to the Metadata accepted by Ocean Protocol.publisher_wallet
-eth Account
of the publisher registering this asset.credentials
- credentialsdictionary
necessary for the asset, which establish who can consume the asset and who cannot.data_nft_address
- hex string, the address of the data NFT. The new asset will be associated with this data NFT address.data_nft_args
- object of DataNFTArguments type if creating a new one.deployed_datatokens
- list of datatokens which are already deployed.services
- list ofService
objects if you want to run multiple services for a datatoken or you have multiple datatokens with a single service each.datatoken_args
- list of objects ofDatatokenArguments
type if creating a new datatokens.encrypt_flag
- bool for encryption of the DDO.compress_flag
- bool for compression of the DDO.wait_for_aqua
- bool for spending time waiting for DDO to be updated in Aquarius.
Returns
tuple
A tuple which contains the data NFT, datatoken and the data asset.
Defined in
Updates Asset
update(
self
,ddo: DDO
,publisher_wallet
,provider_uri: Optional[str] = None
,encrypt_flag: Optional[bool] = True
,compress_flag: Optional[bool] = True
) ->Optional[DDO]
Updates a ddo on-chain.
Parameters
ddo
- DDO to updatepublisher_wallet
- who published this DDOprovider_uri
- URL of service provider. This will be used as base to construct the serviceEndpoint for theaccess
(download) service.encrypt_flag
- boolean value for encryption the DDOcompress_flag
- boolean value for compression the DDO
Returns
DDO
or None
The updated DDO, or None
if updated DDO not found in Aquarius.
Defined in
Resolves Asset
resolve(
self
,did: str
) ->"DDO"
Resolves the asset from Metadata Cache store (Aquarius).
Parameter
did
- identifier of the DDO to be searched & resolved in Aquarius
Returns
DDO
Returns DDO instance.
Defined in
Searches Assets by Text
search(
self
,text: str
) ->list
Searches a DDO by a specific text.
Parameter
text
- string text to search for assets which include it.
Returns
list
A list of DDOs which have matches with the text provided as parameter.
Defined in
Searches Asset by GraphQL Query
query(
self
,query: dict
) ->list
Searches a DDO by a specific query.
Parameter
query
- dictionary type query to search for assets which include it.
Returns
list
A list of DDOs which have matches with the query provided as parameter.
Defined in
Downloads Asset
download_asset(
self
,ddo: DDO
,consumer_wallet
,destination: str
,order_tx_id: Union[str, bytes]
,service: Optional[Service] = None
,index: Optional[int] = None
,userdata: Optional[dict] = None
) ->str
Downloads the asset from Ocean Market.
Parameters
ddo
- DDO to be downloaded.consumer_wallet
- eth Account for the wallet that "ordered" the asset.destination
- destination path, as string, where the asset will be downloaded.order_tx_id
- transaction ID for the placed order, string and bytes formats are accepted.
Optional parameters
service
- optionally if you want to provide theService
object through you downloaded the asset.index
- optionally if you want to download certain files, not the whole asset, you can specify how many files you want to download as positiveinteger
format.userdata
-dictionary
additional data from user.
Returns
str
The full path to the downloaded file as string
.
Defined in
Pays for Access Service
pay_for_access_service(
self
,ddo: DDO
,wallet
,service: Optional[Service] = None
,consume_market_fees: Optional[TokenFeeInfo] = None
,consumer_address: Optional[str] = None
,userdata: Optional[dict] = None
)
Pays for access service by calling initialize endpoint from Provider and starting the order.
Parameters
ddo
- DDO to be downloaded.wallet
- eth Account for the wallet that pays for the asset.
Optional parameters
service
- optionally if you want to provide theService
object through you downloaded the asset.consume_market_fees
-TokenFeeInfo
object which contains consume market fee address, amount and token address.consumer_address
- address for the consumer which pays for the access.userdata
-dictionary
additional data from user.
Returns
str
Return value is a hex string for transaction hash which denotes the proof of starting order.
Defined in
Pays for Compute Service
pay_for_compute_service(
self
,datasets: List[ComputeInput]
,algorithm_data: Union[ComputeInput, AlgorithmMetadata]
,compute_environment: str
,valid_until: int
,consume_market_order_fee_address: str
,wallet
,consumer_address: Optional[str] = None
)
Pays for compute service by calling initializeCompute
endpoint from Provider to retrieve the provider fees and starting the order afterwards.
Parameters
datasets
- list ofComputeInput
objects, each of them includes mandatory the DDO and service.algorithm_data
- which can be either aComputeInput
object which contains the whole DDO and service, either provide just the algorithm metadata asAlgorithmMetadata
.compute_environment
-string
that represents the ID from the chosen C2D environment.valid_until
-UNIX timestamp
which represents until when the algorithm can be used/run.consume_market_order_fee_address
- string address which denotes the consume market fee address for that order and can be the wallet address itself.wallet
- theeth Account
which pays for the compute service
Optional parameters
consumer_address
- is the string address of the C2D environment consumer.
Returns
tuple
Return value is a tuple composed of list of datasets and algorithm data (if exists in result), (datasets, algorithm_data)
.
Defined in
Last updated
Was this helpful?