signedTransaction caller not owner in Cloud Function

i’m planning to send transaction from cloud function, but have error the caller not owner, please ignore the unsafe way it is to put the private key in there, i just want this to work first, if it can.

Moralis.Cloud.define("sign", async function (request) {

  const web3 = Moralis.web3ByChain("0x13881");

    let contractAbi = [

  {

    "anonymous": false,

    "inputs": [

      {

        "indexed": true,

        "internalType": "address",

        "name": "owner",

        "type": "address"

      },

      {

        "indexed": true,

        "internalType": "address",

        "name": "approved",

        "type": "address"

      },

      {

        "indexed": true,

        "internalType": "uint256",

        "name": "tokenId",

        "type": "uint256"

      }

    ],

    "name": "Approval",

    "type": "event"

  },

  {

    "anonymous": false,

    "inputs": [

      {

        "indexed": true,

        "internalType": "address",

        "name": "owner",

        "type": "address"

      },

      {

        "indexed": true,

        "internalType": "address",

        "name": "operator",

        "type": "address"

      },

      {

        "indexed": false,

        "internalType": "bool",

        "name": "approved",

        "type": "bool"

      }

    ],

    "name": "ApprovalForAll",

    "type": "event"

  },

  {

    "anonymous": false,

    "inputs": [

      {

        "indexed": true,

        "internalType": "address",

        "name": "previousOwner",

        "type": "address"

      },

      {

        "indexed": true,

        "internalType": "address",

        "name": "newOwner",

        "type": "address"

      }

    ],

    "name": "OwnershipTransferred",

    "type": "event"

  },

  {

    "anonymous": false,

    "inputs": [

      {

        "indexed": true,

        "internalType": "address",

        "name": "from",

        "type": "address"

      },

      {

        "indexed": true,

        "internalType": "address",

        "name": "to",

        "type": "address"

      },

      {

        "indexed": true,

        "internalType": "uint256",

        "name": "tokenId",

        "type": "uint256"

      }

    ],

    "name": "Transfer",

    "type": "event"

  },

  {

    "inputs": [

      {

        "internalType": "bool",

        "name": "_active",

        "type": "bool"

      }

    ],

    "name": "activatedPresaleMint",

    "outputs": [],

    "stateMutability": "nonpayable",

    "type": "function"

  },

  {

    "inputs": [

      {

        "internalType": "address",

        "name": "to",

        "type": "address"

      },

      {

        "internalType": "uint256",

        "name": "tokenId",

        "type": "uint256"

      }

    ],

    "name": "approve",

    "outputs": [],

    "stateMutability": "nonpayable",

    "type": "function"

  },

  {

    "inputs": [

      {

        "internalType": "uint256",

        "name": "_tokenId",

        "type": "uint256"

      }

    ],

    "name": "burn",

    "outputs": [],

    "stateMutability": "nonpayable",

    "type": "function"

  },

  {

    "inputs": [

      {

        "internalType": "uint8",

        "name": "_rarity",

        "type": "uint8"

      },

      {

        "internalType": "uint8",

        "name": "_percentage",

        "type": "uint8"

      }

    ],

    "name": "changeNormalRarity",

    "outputs": [],

    "stateMutability": "nonpayable",

    "type": "function"

  },

  {

    "inputs": [

      {

        "internalType": "uint8",

        "name": "_rarity",

        "type": "uint8"

      },

      {

        "internalType": "uint8",

        "name": "_percentage",

        "type": "uint8"

      }

    ],

    "name": "changePresaleRarity",

    "outputs": [],

    "stateMutability": "nonpayable",

    "type": "function"

  },

  {

    "inputs": [

      {

        "internalType": "uint256",

        "name": "_rarity",

        "type": "uint256"

      },

      {

        "internalType": "string",

        "name": "_image",

        "type": "string"

      }

    ],

    "name": "initImages",

    "outputs": [],

    "stateMutability": "nonpayable",

    "type": "function"

  },

  {

    "inputs": [

      {

        "internalType": "uint8",

        "name": "_maxlevel",

        "type": "uint8"

      }

    ],

    "name": "initMaxLevel",

    "outputs": [],

    "stateMutability": "nonpayable",

    "type": "function"

  },

  {

    "inputs": [

      {

        "internalType": "uint8",

        "name": "_rarity",

        "type": "uint8"

      },

      {

        "internalType": "string",

        "name": "_special",

        "type": "string"

      }

    ],

    "name": "initSpecials",

    "outputs": [],

    "stateMutability": "nonpayable",

    "type": "function"

  },

  {

    "inputs": [

      {

        "internalType": "uint8",

        "name": "_rarity",

        "type": "uint8"

      },

      {

        "internalType": "string",

        "name": "_weapon",

        "type": "string"

      }

    ],

    "name": "initWeapons",

    "outputs": [],

    "stateMutability": "nonpayable",

    "type": "function"

  },

  {

    "inputs": [],

    "name": "mint",

    "outputs": [],

    "stateMutability": "payable",

    "type": "function"

  },

  {

    "inputs": [],

    "name": "renounceOwnership",

    "outputs": [],

    "stateMutability": "nonpayable",

    "type": "function"

  },

  {

    "inputs": [

      {

        "internalType": "address",

        "name": "from",

        "type": "address"

      },

      {

        "internalType": "address",

        "name": "to",

        "type": "address"

      },

      {

        "internalType": "uint256",

        "name": "tokenId",

        "type": "uint256"

      }

    ],

    "name": "safeTransferFrom",

    "outputs": [],

    "stateMutability": "nonpayable",

    "type": "function"

  },

  {

    "inputs": [

      {

        "internalType": "address",

        "name": "from",

        "type": "address"

      },

      {

        "internalType": "address",

        "name": "to",

        "type": "address"

      },

      {

        "internalType": "uint256",

        "name": "tokenId",

        "type": "uint256"

      },

      {

        "internalType": "bytes",

        "name": "_data",

        "type": "bytes"

      }

    ],

    "name": "safeTransferFrom",

    "outputs": [],

    "stateMutability": "nonpayable",

    "type": "function"

  },

  {

    "inputs": [

      {

        "internalType": "address",

        "name": "operator",

        "type": "address"

      },

      {

        "internalType": "bool",

        "name": "approved",

        "type": "bool"

      }

    ],

    "name": "setApprovalForAll",

    "outputs": [],

    "stateMutability": "nonpayable",

    "type": "function"

  },

  {

    "inputs": [

      {

        "internalType": "address",

        "name": "from",

        "type": "address"

      },

      {

        "internalType": "address",

        "name": "to",

        "type": "address"

      },

      {

        "internalType": "uint256",

        "name": "tokenId",

        "type": "uint256"

      }

    ],

    "name": "transferFrom",

    "outputs": [],

    "stateMutability": "nonpayable",

    "type": "function"

  },

  {

    "inputs": [

      {

        "internalType": "address",

        "name": "newOwner",

        "type": "address"

      }

    ],

    "name": "transferOwnership",

    "outputs": [],

    "stateMutability": "nonpayable",

    "type": "function"

  },

  {

    "inputs": [

      {

        "internalType": "address",

        "name": "_token",

        "type": "address"

      }

    ],

    "stateMutability": "nonpayable",

    "type": "constructor"

  },

  {

    "inputs": [

      {

        "internalType": "address",

        "name": "owner",

        "type": "address"

      }

    ],

    "name": "balanceOf",

    "outputs": [

      {

        "internalType": "uint256",

        "name": "",

        "type": "uint256"

      }

    ],

    "stateMutability": "view",

    "type": "function"

  },

  {

    "inputs": [

      {

        "internalType": "uint256",

        "name": "tokenId",

        "type": "uint256"

      }

    ],

    "name": "getApproved",

    "outputs": [

      {

        "internalType": "address",

        "name": "",

        "type": "address"

      }

    ],

    "stateMutability": "view",

    "type": "function"

  },

  {

    "inputs": [],

    "name": "GXGToken",

    "outputs": [

      {

        "internalType": "contract ERC20",

        "name": "",

        "type": "address"

      }

    ],

    "stateMutability": "view",

    "type": "function"

  },

  {

    "inputs": [

      {

        "internalType": "address",

        "name": "owner",

        "type": "address"

      },

      {

        "internalType": "address",

        "name": "operator",

        "type": "address"

      }

    ],

    "name": "isApprovedForAll",

    "outputs": [

      {

        "internalType": "bool",

        "name": "",

        "type": "bool"

      }

    ],

    "stateMutability": "view",

    "type": "function"

  },

  {

    "inputs": [],

    "name": "name",

    "outputs": [

      {

        "internalType": "string",

        "name": "",

        "type": "string"

      }

    ],

    "stateMutability": "view",

    "type": "function"

  },

  {

    "inputs": [],

    "name": "owner",

    "outputs": [

      {

        "internalType": "address",

        "name": "",

        "type": "address"

      }

    ],

    "stateMutability": "view",

    "type": "function"

  },

  {

    "inputs": [

      {

        "internalType": "uint256",

        "name": "tokenId",

        "type": "uint256"

      }

    ],

    "name": "ownerOf",

    "outputs": [

      {

        "internalType": "address",

        "name": "",

        "type": "address"

      }

    ],

    "stateMutability": "view",

    "type": "function"

  },

  {

    "inputs": [

      {

        "internalType": "uint256",

        "name": "",

        "type": "uint256"

      }

    ],

    "name": "spaceships",

    "outputs": [

      {

        "internalType": "uint256",

        "name": "number",

        "type": "uint256"

      },

      {

        "internalType": "string",

        "name": "image",

        "type": "string"

      },

      {

        "internalType": "string",

        "name": "weapon1",

        "type": "string"

      },

      {

        "internalType": "string",

        "name": "weapon2",

        "type": "string"

      },

      {

        "internalType": "string",

        "name": "weapon3",

        "type": "string"

      },

      {

        "internalType": "string",

        "name": "special",

        "type": "string"

      },

      {

        "internalType": "uint8",

        "name": "rarity",

        "type": "uint8"

      },

      {

        "internalType": "uint8",

        "name": "level",

        "type": "uint8"

      },

      {

        "internalType": "uint256",

        "name": "durability",

        "type": "uint256"

      },

      {

        "internalType": "uint256",

        "name": "health",

        "type": "uint256"

      },

      {

        "internalType": "uint256",

        "name": "speed",

        "type": "uint256"

      }

    ],

    "stateMutability": "view",

    "type": "function"

  },

  {

    "inputs": [

      {

        "internalType": "bytes4",

        "name": "interfaceId",

        "type": "bytes4"

      }

    ],

    "name": "supportsInterface",

    "outputs": [

      {

        "internalType": "bool",

        "name": "",

        "type": "bool"

      }

    ],

    "stateMutability": "view",

    "type": "function"

  },

  {

    "inputs": [],

    "name": "symbol",

    "outputs": [

      {

        "internalType": "string",

        "name": "",

        "type": "string"

      }

    ],

    "stateMutability": "view",

    "type": "function"

  },

  {

    "inputs": [

      {

        "internalType": "uint256",

        "name": "tokenId",

        "type": "uint256"

      }

    ],

    "name": "tokenURI",

    "outputs": [

      {

        "internalType": "string",

        "name": "",

        "type": "string"

      }

    ],

    "stateMutability": "view",

    "type": "function"

  }

];

    let contract = new web3.eth.Contract(contractAbi, "MY_CONTRACT_ADDRESS");

    let transaction = contract.methods.initMaxLevel(30);

    let options = {

        to  : transaction._parent._address,

        data: transaction.encodeABI(),

        gas : await transaction.estimateGas(),

    };

    let signedTransaction = await web3.eth.accounts.signTransaction(options,"CONTRACT_OWNER_PRIVATEKEY");

    //let transactionReceipt = await web3.eth.sendSignedTransaction(signedTransaction.rawTransaction);

   

    return signedTransaction;

})

Hi @riocascade
Can you add a callback function and check the error and also forward it to me?

Check the link for how to use callback in signtransaction()

https://web3js.readthedocs.io/en/v1.2.11/web3-eth-accounts.html#signtransaction

For the note: https://docs.moralis.io/moralis-server/cloud-code/cloud-functions#web3

its not safe to upload private key on moralis cloud

hello, cloud functions are only used for specific things , why do you want to be able to call a smart contract function in the cloud function ?

let say i create a nft game, i have increaselevel function in smartcontract, but i don’t want player to increase the level themself in explorer.

so i want the cloud function to trigger the function, the function have onlyowner modifier.
i heard moralis cloud function can do this, or i mistaken, and still need nodejs server?

@taha it’s give error Uncaught (in promise) Error: Returned error: execution reverted: Ownable: caller is not the owner

the smartcontract function is have onlyowner modifier.

From that error message it looks like the function was not called by the owner

1 Like

@cryptokid but this code should be doing transaction as contract owner right?

@riocascade the private you are passing is not the owner of contract private key

@taha i deploy the smart contract using this account, export the private key from metamask, check the owner of contract, and it return same account.

i want to know if send signed transaction in cloud function is possible or not even if it unsafe? or because of the limitation it will result in weird behavior?

If you made that transaction on chain, you can look on chain to see what happened in a block explorer

this is not idea for cloud functions and even if you are able to use the owner private keys to call the function, you can still do this in your game (js or c# or react) and this is the security most people want but smart contracts dont have those securities, you can use your database to make the player level up

1 Like

Hi @riocascade
Took some time with busy schedule, but i was able to sign tranx in moralis cloud

Moralis.Cloud.define("sign", async (request) => {
		    const web3 = Moralis.web3ByChain("0x13881");
         	let signedTransaction = web3.eth.accounts.signTransaction(
              	{to: '0x96402b32bF48BfE2Fa74B7cB8ec59BB8A36cDa1d', value: '1000000000',gas: 2000000}, 
                '1439d4d132d7c07d322c6d5b4b1c8e364a4f24fdcec92d39f86f97a78958ae57');
			return signedTransaction;
})

Conclusion: Yes, you can sign transaction on Moralis cloud. Hence you will have to debug your code and check there might be some issue with retrieving correct key or something.

i don’t know, i still got the caller is not owner error message, even though i already put the contract owner private key.

fyi, i’m using openzeppelin ownable.

Can you send me your whole code file? with contract address as well?

my smartcontract code like this, but i can’t give you my private key, my cloud function code you can check the code snippet in above post

// contracts/GameItem.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract GalaxySpaceshipToken is ERC721, Ownable {
    mapping (uint256 => address) internal tokenOwner;
    using Counters for Counters.Counter;
    Counters.Counter private _tokenIds;

    ERC20 public GXGToken;

    string[] commonImages;//uri
    string[] uncommonImages;//uri
    string[] rareImages;//uri
    string[] legendaryImages;//uri
    string[] commonWeapons;
    string[] uncommonWeapons;
    string[] rareWeapons;
    string[] legendaryWeapons;
    string[] commonSpecials;
    string[] uncommonSpecials; 
    string[] rareSpecials;
    string[] legendarySpecials;
    uint[] presaleRarityPercentages;
    uint[] normalRarityPercentages;
    uint commonImagesCount = 0;
    uint uncommonImagesCount = 0;
    uint rareImagesCount = 0;
    uint legendaryImagesCount = 0;
    uint commonSpecialsCount = 0;
    uint uncommonSpecialsCount = 0;
    uint rareSpecialsCount = 0;
    uint legendarySpecialsCount = 0;
    uint commonWeaponsCount = 0;
    uint uncommonWeaponsCount = 0;
    uint rareWeaponsCount = 0;
    uint legendaryWeaponsCount = 0;

    bool presale = true;
    uint public minPrice = 100;

    struct Spaceship{
        uint number;
        string image;        
        string weapon1;
        string weapon2;
        string weapon3;
        string special;
        uint8 rarity;//4 rarity
        uint durability;
        uint health;
        uint speed;//1-5
    }

    uint nonce = 0;
    Spaceship[] public spaceships;
    
  
    constructor(address _token) ERC721("Galaxy Spaceship V1.3", "GXS")
    {
        presaleRarityPercentages.push(50);
        presaleRarityPercentages.push(30);
        presaleRarityPercentages.push(17);
        presaleRarityPercentages.push(3);

        normalRarityPercentages.push(70);
        normalRarityPercentages.push(30);
        GXGToken = ERC20(_token);
    }    

    function mintToken(address toAdr) public returns(uint256){
        require(commonImages.length > 0);
        require(uncommonImages.length > 0);
        require(rareImages.length > 0);
        require(legendaryImages.length > 0);
        require(commonWeapons.length > 0);
        require(uncommonWeapons.length > 0);
        require(rareWeapons.length > 0);
        require(legendaryWeapons.length > 0);
        require(commonSpecials.length > 0);
        require(uncommonSpecials.length > 0);
        require(rareSpecials.length > 0);
        require(legendarySpecials.length > 0);
        
        require(GXGToken.allowance(msg.sender, address(this)) >= minPrice, "Not enough of GXG token");//To ensure they will deposit the right amount
        GXGToken.transferFrom(msg.sender, owner(), minPrice);

        _tokenIds.increment();
        uint256 _tokenId = _tokenIds.current();
        tokenOwner[_tokenId] = msg.sender;

        Spaceship memory s;

        //rarity check
        uint _rarityRand = rand(0, 100);
        if(presale){
            if(_rarityRand<presaleRarityPercentages[3]){
                s.rarity = 4;
            }else{
                _rarityRand = rand(0, 100);
                if(_rarityRand<presaleRarityPercentages[2]){
                    s.rarity = 3;
                }else{
                    _rarityRand = rand(0, 100);
                    if(_rarityRand<presaleRarityPercentages[1]){
                        s.rarity = 2;
                    }else{
                        s.rarity = 1;
                    }
                }
            }
        }else{
            if(_rarityRand<normalRarityPercentages[1]){
                s.rarity = 2;
            }else{
                s.rarity = 1;
            }
        }
        
        s = setAttributes(s);

        s.number = _tokenId;
        
        spaceships.push(s);
        
        _safeMint(toAdr, _tokenId);

        return _tokenId;
    }


    function removeWeaponsTemp(string[] memory _weaponsTemp, uint _index) pure internal returns(string[] memory){
        _weaponsTemp[_index] = _weaponsTemp[_weaponsTemp.length - 1];

        return _weaponsTemp;
    }

    function setAttributes(Spaceship memory s) internal returns(Spaceship memory){
        string[] memory _weaponsTemp;
        string[] memory _specialsTemp; 
        uint _weaponRand; 
        uint i; 
        uint index;
        uint allWeaponCount;
        uint allSpecialCount;        
        
        if(s.rarity == 1){
            s.image = commonImages[rand(0, commonImagesCount-1)];
            s.weapon1 = commonWeapons[rand(0, commonWeaponsCount-1)];
            s.special = commonSpecials[rand(0, commonSpecialsCount-1)];              
            s.durability = rand(100,200);
            s.health = 3;
            s.speed = 1;
        }else if(s.rarity == 2){
            allWeaponCount = commonWeaponsCount+uncommonWeaponsCount;
            _weaponsTemp = new string[] (allWeaponCount);
            allSpecialCount = commonSpecialsCount+uncommonSpecialsCount;
            _specialsTemp = new string[] (allSpecialCount);
            index = 0;
            for(i=0;i<commonWeaponsCount;i++){
                _weaponsTemp[index] = commonWeapons[i];
                index++;
            }
            for(i=0;i<uncommonWeaponsCount;i++){
                _weaponsTemp[index] = uncommonWeapons[i];
                index++;
            }
            index = 0;
            for(i=0;i<commonSpecialsCount;i++){
                _specialsTemp[index] = commonSpecials[i];
                index++;
            }
            for(i=0;i<uncommonSpecialsCount;i++){
                _specialsTemp[index] = uncommonSpecials[i];
                index++;
            }

            s.image = uncommonImages[rand(0, uncommonImagesCount-1)];
            s.special = _specialsTemp[rand(0, _specialsTemp.length-1)];
            s.durability = rand(200,300);
            s.health = rand(3,4);
            s.speed = rand(1,3);

            _weaponRand = rand(0, allWeaponCount-1);
            s.weapon1 = _weaponsTemp[_weaponRand];  
            _weaponsTemp[_weaponRand] = _weaponsTemp[_weaponsTemp.length - 1];            
            allWeaponCount--;

            _weaponRand = rand(0, allWeaponCount-1);
            s.weapon2 = _weaponsTemp[_weaponRand];  
        }else if(s.rarity == 3){
            allWeaponCount = commonWeaponsCount+uncommonWeaponsCount+rareWeaponsCount;
            _weaponsTemp = new string[] (allWeaponCount);
            allSpecialCount = commonSpecialsCount+uncommonSpecialsCount+rareSpecialsCount;
            _specialsTemp = new string[] (allSpecialCount);
            index = 0;
            for(i=0;i<commonWeaponsCount;i++){
                _weaponsTemp[index] = commonWeapons[i];
                index++;
            }
            for(i=0;i<uncommonWeaponsCount;i++){
                _weaponsTemp[index] = uncommonWeapons[i];
                index++;
            }
            for(i=0;i<rareWeaponsCount;i++){
                _weaponsTemp[index] = rareWeapons[i];
                index++;
            }
            index = 0;
            for(i=0;i<commonSpecialsCount;i++){
                _specialsTemp[index] = commonSpecials[i];
                index++;
            }
            for(i=0;i<uncommonSpecialsCount;i++){
                _specialsTemp[index] = uncommonSpecials[i];
                index++;
            }
            for(i=0;i<rareSpecialsCount;i++){
                _specialsTemp[index] = rareSpecials[i];
                index++;
            }
            s.image = rareImages[rand(0, rareImagesCount-1)];
            s.special = _specialsTemp[rand(0, _specialsTemp.length-1)];
            s.durability = rand(300,400);
            s.health = rand(3,5);
            s.speed = rand(2,4);

            _weaponRand = rand(0, allWeaponCount-1);
            s.weapon1 = _weaponsTemp[_weaponRand];  
            _weaponsTemp[_weaponRand] = _weaponsTemp[_weaponsTemp.length - 1];
            allWeaponCount--;

            _weaponRand = rand(0, _weaponsTemp.length-1);
            s.weapon2 = _weaponsTemp[_weaponRand];  
            _weaponsTemp[_weaponRand] = _weaponsTemp[_weaponsTemp.length - 1];
            allWeaponCount--;

            _weaponRand = rand(0, _weaponsTemp.length-1);
            s.weapon3 = _weaponsTemp[_weaponRand];  
        }else if(s.rarity == 4){
            allWeaponCount = uncommonWeaponsCount+rareWeaponsCount+legendaryWeaponsCount;
            _weaponsTemp = new string[] (allWeaponCount);
            index = 0;
            for(i=0;i<uncommonWeaponsCount;i++){
                _weaponsTemp[index] = uncommonWeapons[i];
                index++;
            }
            for(i=0;i<rareWeaponsCount;i++){
                _weaponsTemp[index] = rareWeapons[i];
                index++;
            }
            for(i=0;i<legendaryWeaponsCount;i++){
                _weaponsTemp[index] = legendaryWeapons[i];
                index++;
            }

            s.image = legendaryImages[rand(0, legendaryImagesCount-1)];
            s.special = legendarySpecials[rand(0, legendarySpecialsCount-1)];
            s.durability = rand(400,500);
            s.health = rand(4,5);
            s.speed = rand(3,5);

            _weaponRand = rand(0, allWeaponCount-1);
            s.weapon1 = _weaponsTemp[_weaponRand];  
            _weaponsTemp[_weaponRand] = _weaponsTemp[_weaponsTemp.length - 1];
            allWeaponCount--;

            _weaponRand = rand(0, allWeaponCount-1);
            s.weapon2 = _weaponsTemp[_weaponRand];  
            _weaponsTemp[_weaponRand] = _weaponsTemp[_weaponsTemp.length - 1];
            allWeaponCount--;

            _weaponRand = rand(0, allWeaponCount-1);
            s.weapon3 = _weaponsTemp[_weaponRand];  
        }
        return s;
    }

    function burn(uint256 _tokenId) public onlyOwner {
        super._burn(_tokenId);
    }

    function initImages(uint _rarity, string memory _image) public onlyOwner {
        if(_rarity == 1){
            commonImages.push(_image);
            commonImagesCount++;
        }else if(_rarity == 2){
            uncommonImages.push(_image);
            uncommonImagesCount++;
        }else if(_rarity == 3){
            rareImages.push(_image);
            rareImagesCount++;
        }else if(_rarity == 4){
            legendaryImages.push(_image);
            legendaryImagesCount++;
        }
    }

    function activatedPresaleMint(bool _active) public onlyOwner{
        presale = _active;
    }

    function changePresaleRarity( uint8 _rarity, uint8 _percentage) public onlyOwner {
       require(_rarity>0 && _rarity<=4 && _percentage>0 && _percentage <=100);
        if(_rarity == 1){
            presaleRarityPercentages[0]=_percentage;
        }else if(_rarity == 2){
            presaleRarityPercentages[1]=_percentage;
        }else if(_rarity == 3){
            presaleRarityPercentages[2]=_percentage;
        }else if(_rarity == 4){
            presaleRarityPercentages[3]=_percentage;
        }
    }

    function changeNormalRarity( uint8 _rarity, uint8 _percentage) public onlyOwner {
       require(_rarity>0 && _rarity<=2 && _percentage>0 && _percentage <=100);
        if(_rarity == 1){
            normalRarityPercentages[0]=_percentage;
        }else if(_rarity == 2){
            normalRarityPercentages[1]=_percentage;
        }
    }

    function initWeapons(uint8 _rarity, string memory _weapon) public onlyOwner {
        if(_rarity == 1){
            commonWeapons.push(_weapon);
            commonWeaponsCount++;
        }else if(_rarity == 2){
            uncommonWeapons.push(_weapon);
            uncommonWeaponsCount++;
        }else if(_rarity == 3){
            rareWeapons.push(_weapon);
            rareWeaponsCount++;
        }else if(_rarity == 4){
            legendaryWeapons.push(_weapon);
            legendaryWeaponsCount++;
        }
        
    }

    function initSpecials(uint8 _rarity, string memory _special) public onlyOwner {
        if(_rarity == 1){
            commonSpecials.push(_special);
            commonSpecialsCount++;
        }else if(_rarity == 2){
            uncommonSpecials.push(_special);
            uncommonSpecialsCount++;
        }else if(_rarity == 3){
            rareSpecials.push(_special);
            rareSpecialsCount++;
        }else if(_rarity == 4){
            legendarySpecials.push(_special);
            legendarySpecialsCount++;
        }
        
    }

    function rand(uint min, uint max) internal returns (uint){
        if(max>min){
            nonce++;
            uint randomNum = uint(keccak256(abi.encodePacked(nonce)));
            uint rangeNum = (max-min)+1;
            uint moded = randomNum%rangeNum;
            return moded+min;
        }else{
            return min;
        }
    }

    function initPrice(uint price) public onlyOwner {
        minPrice = price;
    }

    function clearImages(uint _rarity)external onlyOwner{
        if(_rarity==1){
            delete commonImages;
            commonImagesCount = 0;
        }else if(_rarity==2){
            delete uncommonImages;
            uncommonImagesCount = 0;
        }else if(_rarity==3){
            delete rareImages;
            rareImagesCount = 0;
        }else if(_rarity==4){
            delete legendaryImages;
            legendaryImagesCount = 0;
        }
    }

    function clearWeapons(uint _rarity)external onlyOwner{
        if(_rarity==1){
            delete commonWeapons;
            commonWeaponsCount =0;
        }else if(_rarity==2){
            delete uncommonWeapons;
            uncommonWeaponsCount =0;
        }else if(_rarity==3){
            delete rareWeapons;
            rareWeaponsCount =0;
        }else if(_rarity==4){
            delete legendaryWeapons;
            legendaryWeaponsCount =0;
        }
    }

    function clearSpecials(uint _rarity)external onlyOwner{
        if(_rarity==1){
            delete commonSpecials;
            commonSpecialsCount = 0;
        }else if(_rarity==2){
            delete uncommonSpecials;
            uncommonSpecialsCount = 0;
        }else if(_rarity==3){
            delete rareSpecials;
            rareSpecialsCount = 0;
        }else if(_rarity==4){
            delete legendarySpecials;
            legendarySpecialsCount = 0;
        }
    }

    function getImages(uint _rarity)view public returns(string[] memory images){
        if(_rarity==1){
            return commonImages;
        }else if(_rarity==2){
            return uncommonImages;
        }else if(_rarity==3){
            return rareImages;
        }else if(_rarity==4){
            return legendaryImages;
        }
    }

    function getWeapons(uint _rarity)view public returns(string[] memory weapons){
        if(_rarity==1){
            return commonWeapons;
        }else if(_rarity==2){
            return uncommonWeapons;
        }else if(_rarity==3){
            return rareWeapons;
        }else if(_rarity==4){
            return legendaryWeapons;
        }
    }

    function getSpecials(uint _rarity)view public returns(string[] memory specials){
        if(_rarity==1){
            return commonSpecials;
        }else if(_rarity==2){
            return uncommonSpecials;
        }else if(_rarity==3){
            return rareSpecials;
        }else if(_rarity==4){
            return legendarySpecials;
        }
    }

    function get
    
}

my intention is want to run the onlyowner function from cloud, in example the initPrice function in smartcontract

@riocascade
Send me contract address :slight_smile: Not the whole contract but it is helpful too.

Can send me contract address?
I know i can deploy it too and try but it will be a bit long process

Thanks in advance

@taha ah sorry, here’s the nft contract address 0x0f8eDF0651caE2D0EAB198C55aCafE1321d47d66

it’s on mumbai chain