You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello i try to deploy my contract using truffle on my private ethereum network(geth). I have connect an account to metamask and i have mine ethers. So i deploy the contract and when react with a function the metamask gives me this error.
contract code
```
pragma solidity ^0.5.8;
contract Creation {
int basiclife=50;
struct hero {
string name;
int life;
int lvl;
int xp;
int attack;
int winCount;
int trophies;
int lossCount;
}
hero[] public heroes;
struct enemy {
string name;
int life;
int lvl;
int xp;
int attack;
}
enemy[] public enemies;
mapping (uint => address) public herotoowner;
mapping (address => uint) public heroCount;
mapping (uint => address) public monstertoowner;
uint public monsterCount;
function createhero(string memory _name) public {
require(heroCount[msg.sender] == 0);
uint id= heroes.push(hero(_name,basiclife,1,0,20,0,0,0))-1;
herotoowner[id] = msg.sender;
heroCount[msg.sender]++;
}
function enemyRage(int _herolvl) public {
uint id=enemies.push(enemy("Rage",20*_herolvl,_herolvl,7*_herolvl,5*_herolvl))-1;
monstertoowner[id] = msg.sender;
monsterCount++;
}
function enemyDerpina(int _herolvl) public {
uint id=enemies.push(enemy("Derpina",40*_herolvl,_herolvl,14*_herolvl,10*_herolvl))-1;
monstertoowner[id] = msg.sender;
monsterCount++;
}
function getHerosByOwner(address owner) external view returns( uint ) {
uint result =3;
for (uint i = 0; i < 3; i++) {
if (herotoowner[i] == owner) {
result = i;
break;
}
}
return result;
}
function getmonstersByOwner(address owner) external view returns( uint ) {
uint result =0;
for (uint i = enemies.length ; i > 0 ; i--) {
if (monstertoowner[i] == owner) {
result = i;
break;
}
}
return result;
}
uint nonce=0;
function randNum(int _num) private returns(int) { //sinartisi gia tixaies times
int randomnumber = int(keccak256(abi.encodePacked(now, msg.sender, nonce))) % _num;
if (randomnumber <=0) {
randomnumber=(-1)*randomnumber;
}
nonce++;
return randomnumber;
}
function attack_hero(uint _heroid, uint _monsterid, int _num ) external returns(string memory, int,int,int,int ) {
hero storage myhero = heroes[_heroid];
enemy storage monster = enemies[_monsterid];
int attackofhero=0;
if(_num==0) {
attackofhero=randNum(myhero.attack);
}
monster.life=monster.life - attackofhero;
int attackofmonster=randNum(monster.attack);
myhero.life=myhero.life - attackofmonster;
if (monster.life <= 0 && myhero.life >0) {
myhero.winCount++;
myhero.xp+=monster.xp;
if (randNum(100) > 50 ){
myhero.trophies++;
}
return("win",myhero.lvl,myhero.xp,myhero.life,myhero.trophies);
}
if (myhero.xp>=10+2*myhero.lvl){
myhero.lvl++;
myhero.xp=0; //reset you xp
myhero.life=basiclife*myhero.lvl;
myhero.attack=myhero.attack*myhero.lvl;
}
if (myhero.life <= 0 ) { //ita
myhero.lossCount++;
return("dead",myhero.lossCount,myhero.life,myhero.lvl,myhero.trophies);
}
return("attack",myhero.life,attackofhero,monster.life,attackofmonster);
}
function resurrection(uint _heroid) public {
hero storage myhero = heroes[_heroid];
myhero.life=basiclife*myhero.lvl;
}
}
Hello i try to deploy my contract using truffle on my private ethereum network(geth). I have connect an account to metamask and i have mine ethers. So i deploy the contract and when react with a function the metamask gives me this error.
contract code
```
pragma solidity ^0.5.8;
{
"config":{
"chainId":15,
"homesteadBlock":0,
"eip155Block":0,
"eip158Block":0
},
"nonce":"0x0000000000000042",
"mixhash":"0x000000000000000000000000000000000000000000000000000000000
0000000",
"difficulty":"0x200",
"alloc": {},
"coinbase": "0x0000000000000000000000000000000000000000",
"timestamp": "0x00",
"parentHash":"0x0000000000000000000000000000000000000000000000000000000
000000000",
"gasLimit":"0xffffffff",
"alloc":{
}
}
}
The text was updated successfully, but these errors were encountered: