Review
object could look like this:request
object, so we can use that to pass up the movie name. The entire Moralis JavaScript SDK is available in the cloud environment, so we can use that to query over Review
objects. Together, the code to implement averageStars
looks like this:averageStars
and hello
is that we have to provide the parameter that will be accessed in request.params.movie
when we call the Cloud Function. Read on to learn more about how Cloud Functions can be called.require
statement.count
variable.moralis-admin-cli
.request
- The request object contains information about the request. The following fields are set:params
- The parameters object is sent to the function by the client.user
- The Moralis.User
that is making the request. This will not be set if there was no logged-in user./functions/
.?_ApplicationId=yourMoralisAppId
.¶m1=value¶m2=value
.useMasterKey:true
in the requests that require the master key.useMasterKey:true
averageStars
example. If you wanted to make sure that request.params.movie
is provided, and that averageStars
can only be called by logged-in users, you could add a validator object to the function.request.params.movie
is defined, as well as request.user
.request.params.movie
is defined, but also that it's the correct data type. You can do this by providing an Object
to the fields
parameter in the "Validator."request.params.movie
is defined.request.params.movie
is a String.request.params.movie
is less than 20 characters.request.user
is defined.request.user.get('accType')
is defined.request.user.get('accType')
is equal to โreviewer.โrequireMaster
: Whether the function requires a masterKey
to run.requireUser
: Whether the function requires a request.user
to run.validateMasterKey
: Whether the validator should run on masterKey
(defaults to false).fields
: An Array
or Object
of fields that are required on the request.requireUserKeys
: An Array
of fields to be validated on request.user
..fields
are:type
: The type of the request.params[field]
or request.object.get(field)
.default
: What the field should default to if itโs null
.required
: Whether the field is required.options
: A singular option, an array of options, or a custom function of allowed values for the field.constant
: Whether the field is immutable.error
: A custom error message if validation fails.async
and promises here, but try to keep the validation as simple and fast as possible so your cloud requests resolve quickly.validateMasterKey:true
is set. However, if you set your validator to a function, the function will always run.units
function you always need to specify a method
and a value
.1000000000000000000
0.001
64
1000
Moralis.ethersByChain()
, you'll get an object with the provider
and ethers
libraries.web3
object by supplying the chainId
for the blockchain you wish to connect to.web3
instance returned by Moralis.web3ByChain()
or Moralis.ethersByChain()
cannot sign transactions. There is a way to sign a transaction using a private key, but this is NOT recommended for security reasons.0x1
0x3
0x4
0x5
0x2a
0x38
0x61
0x89
0x13881
0x539
web3
instance, you can use it to make contract calls by constructing a contract instance with the ABI and contract address.Moralis.Web3.abis.erc20
Moralis.Web3.abis.erc721
Moralis.Web3.abis.erc1155
web3.eth.Contract
section of the Web3.js docs.Moralis.web3ByChain()
cannot sign transactions. In the near future, it may be possible to do this with custom plugins. For now, if you need to make on-chain contract interactions, consider doing them on the frontend or create a NodeJS backend where you have access to Truffle's HdWalletProvider./truffle/build/contracts/myContract.json
./artifacts/contracts/myContract.sol/myContract.json
.sourceType
source
sourceType
{ "path": "https://ipfs.moralis.io:2053/ipfs/QmYrUVhr1f6ZpZ4jrmi7mSv5X8MGjxxrgaERWde3cFASL6" }
{ "path": "https://ipfs.moralis.io:2053/ipfs/QmeYY26fCN4t2Apo9Nqix5ZDhJwcjoyDVLLz85TLkoiqpn" }
{ "path": "https://ipfs.moralis.io:2053/ipfs/QmWowsJ74rYCHUYhag83Puky1qZTSsdj3n7bT2ejE2NvCJ" }
{ "path": "https://ipfs.moralis.io:2053/ipfs/QmaZRSn8cHKUN5LsvuY6M8a5LzV76uFKeZ9khthPj2rHhw" }
{ "path": "https://ipfs.moralis.io:2053/ipfs/QmeYY26fCN4t2Apo9Nqix5ZDhJwcjoyDVLLz85TLkoiqpn" }