Using moralis data in a solidity smart contract?

Hello,

I’m a bit new to solidity, so let me know if I am misunderstanding something.

I want to use Moralis data in a Smart Contract. Specifically, I want to run some queries about the data and then determine who would get a prize of AVAX, and store that value on the contract.

I am not sure how to approach this.

I do not want to query this information client-side because I do not want the possibility of the client manipulating it.

So here’s some ideas

  1. Query Moralis from the smart contract (Oracle), but I can’t find any tutorials of contracts pulling Moralis API…only things like Chainlink. Not sure if it’s even possible.
  2. Query in cloud code. I saw a thread that seems to say we can run contract function from cloud code, but I don’t see how you could have a client sign a transaction if we are using cloud code. Mostly I see the utility of getting data from the contract…so I don’t know how helpful that would be.
  3. Send the data to the contract on a regular basis. This would be executing a contract function to store data on the contract from moralis.

Are there other options? Which is sensible?

Okay, I guess the answer is user > smart contract > chainlink > cloud function, and back again

I think you might do so by using Get Uint256 Job from Chainlink, which you can search in market.link and have the Cloud function called as a REST API

1 Like

Thanks. I am diving into chainlink now, and it seems either really expensive or really cheap. Lets say i want to grab an object fro moralis, it would cost 1 LINK.

Is that the current price of $17 or $17 divided by 10^18?

1 Like

chainlink will have to make a request on chain, and it will cost gas fees to make that request, so the price should cover at least the gas price for a transaction

Yes it could be quite costly, if you go to other chains like Polygon or BSC it’ll be cheaper though usually. It really depends on the data provider, but tends to be more expensive if the gas fees of the network is expensive, like in Ethereum

1 Like

I’m STILL not clear on the cost. This node to get 1 uint from an API is .10 LINK. Since the price of LINK on the charts is $17, does that mean it cost $1.70 to just get a single uint?

Yes it is :raised_hands: sounds like you understand it

Unfortunately that’s too expensive by an order of magnitude. :frowning: