infura.info 405 (POST Method Not Allowed)

ahmed_chahmed_ch Posts: 7Member
I have deployed a smart contract in the testnet using MetaMask and a solidity online compiler(injected web3):
pragma solidity ^0.4.7;
contract SimpleStorage {

uint public storedData;
string public name = "ahmed";
event Print(uint);

function SimpleStorage(uint initialValue) {
storedData = initialValue;
}

function set(uint x) returns (uint){
storedData = x;
Print(storedData);
return storedData;
}

function get() constant returns (uint retVal) {
return storedData;
}
}


I used the ropsten.infura.io provider to interact with the contract in the testnet I can call string "name" from console and it returns value successfully. But when i want to call the function "set" or "get", I got an error:

POST https://ropsten.infura.io/ahmed_charef 405 (Method Not Allowed)
Error: Invalid JSON RPC response: ""

This is my js file to call function:
web3 = new Web3(new Web3.providers.HttpProvider("https://ropsten.infura.io/ahmed_charef"));

contractAddress = "0x752fB8626c5bEf519EfC661F6694fbE497405FfE"
ABI = [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"storedData","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"set","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"retVal","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[{"name":"initialValue","type":"uint256"}],"payable":false,"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"","type":"uint256"}],"name":"Print","type":"event"}]

myContract = web3.eth.contract(ABI).at(contractAddress);

myContract.name(function(err, res){
console.log(res);
})

function voteForCand() {

myContract.set("20");
}

Sign In or Register to comment.