Non view functions are returning value on Solidity. So I thought that maybe I can return these values to game. I have some transactions that is used multiple times, and users call them multiple times a day. If I search for an event everytime after a transaction executed it is multiplying the server requests. Is there a better solution for this?
Non view functions cannot return value, idk how your sol code is structured
it has to be view to return a function, but if it is view, it cannot be payable and those are state mutability with and they cannot be together, so idk what exactly you are asking ?
if you dont mind, post your sol code ?
There is a way to return view functions: https://github.com/ethereum-boilerplate/ethereum-unity-boilerplate#runcontractfunction
@Epica https://docs.moralis.io/moralis-dapp/web3-sdk/native#runcontractfunction
This is the docs for runcontractfunction for view state mutability
It didn’t give me an error when using payable
and returns
parameters at the same time without the view
. So I thought that I can use it to return some variables. Thank you for the info!
function mint() external payable nonReentrant returns (uint256) {
require(msg.value == ethFee);
_tokenIds.increment();
uint tokenId = _tokenIds.current();
emit Mint(tokenId);
_mint(msg.sender, tokenId);
return tokenId;
}
So Moralis Unity SDK don’t work for iOS … ?
It has been. I will need to try a. iOS build this takes a bit to set up …
You can use the call you are doing paired with a read via the Web3API using the transaction hash.
It appears in vs 1.0.9 that the auth process is not applying the wallet filter for iOS so it is attempting to load all wallets. Continuing to investigate …
Thanks so much, trying to find a solution here too… but struggling hard hah
Hi there,
If I want my users to farm coins in game that are erc20s how can I manage transferring funds from my contract owner to the player automatically without having to sign each transaction ?
Same question for NFTs.
Thanks a lot
well, you can automate contract functions with gelato or maybe have cloud code with private keys doing the sending, but if something goes wrong, it could be exploited
Ok thanks for the tip !
What about your claimNFT script for the mug ?
I have a fix for the iOS issue. Testing that and a couple other things. I should have a merge to main by the end of the day unless I run into any issues.
Is there any way to check if a transaction is reverted or failed? I’m using SendTransactionAsync
method to make a transaction, but it didn’t return any values if the transaction is reverted. Also, I can’t understand if the transaction is failed or not.
if you use /transaction/{transaction_hash}
endpoint,
you should see receipt_status": "1"
if it is one, it passed, but if it is 0, it failed
Thanks for the great support !
Hi,
I am creating a React app with Moralis SDK that also hosts a Unity game on the client side.
The goal is to prevent the user from having to authenticate both in React and Unity. We have Player data stored in the Moralis Mongo DB that inherits the ACL of the User. We would like to access the Player data on the Unity game load and update player data on game level completion.
Is it possible to safely use the initial authorization used in the react code to authenticate within the unity game at the same time? If not, is it possible to safely pass data into the Unity canvas utilizing the auth present in React?
Yes it is. When the user authenticates in the REACT app, a sessionToken is returned within the user object. Pass this to the Unity App.
When the Unity Game starts instead of loading the Authentication scene, initialize Moralis as normal and then run
MoralisInterface.GetClient().UserFromSession(SESSIONTOKEN_HERE);
This will load the user from the sessionToken. The loaded user will be set to the the CurrentUser and other Moralis interactions happens normally.
awesome! I will try this out, many thanks.
Just an update - I have a couple of failing integration tests that I am working through (unrelated to the iOS fix) so I have not merged to main yet.
If you want a head start the dev branch is bugs/issue_81. This is a use at your own risk situation though. As I mentioned, not all tests are currently passing.