Please make sure that you've unlocked your eth.account[0]
by executing personal.unlockAccount(eth.account[0])
before progressing.
(Or whatever account you're sending from).
This code will deploy the contract to the network:
var mortalContract = web3.eth.contract([{"constant":false,"inputs":[],"name":"kill","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"val","type":"string"}],"name":"set","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"}]);
var mortal = mortalContract.new(
{
from: web3.eth.accounts[0],
data: '0x6060604052341561000f57600080fd5b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506103948061005e6000396000f300606060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806341c0e1b51461005c5780634ed3885e146100715780636d4ce63c146100ce575b600080fd5b341561006757600080fd5b61006f61015c565b005b341561007c57600080fd5b6100cc600480803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919050506101ed565b005b34156100d957600080fd5b6100e1610207565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610121578082015181840152602081019050610106565b50505050905090810190601f16801561014e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156101eb576000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16ff5b565b80600190805190602001906102039291906102af565b5050565b61020f61032f565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102a55780601f1061027a576101008083540402835291602001916102a5565b820191906000526020600020905b81548152906001019060200180831161028857829003601f168201915b5050505050905090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106102f057805160ff191683800117855561031e565b8280016001018555821561031e579182015b8281111561031d578251825591602001919060010190610302565b5b50905061032b9190610343565b5090565b602060405190810160405280600081525090565b61036591905b80821115610361576000816000905550600101610349565b5090565b905600a165627a7a72305820a73bbe00b6880e0b6a1a9642179e82cc6ad84cac8cd8d5e76180484b2462d68c0029',
gas: 3000000
}, function(e, contract){
console.log(e, contract);
if (typeof contract.address != 'undefined') {
console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
}
})
This code will aid further interactions with the contract:
var MortalContract = web3.eth.contract(mortalContract.abi);
var mortalContractInstance = MortalContract.at(mortal.address);
mortalContractInstance.set("thisIsAnInterestingString", {from: eth.accounts[0], gas: 3000000});
mortalContractInstance.get();
The above code will deploy your mortal
contract, set the string and then retrieve the string. The last call to mortalContractInstance.get();
will return the string that was set i.e. "thisIsAnInterestingString"
.
UPDATE: As a side note, I retrieved the abi and compiled bytecode of your mortal
contract from here. I could've done this manually but this online tool made it easier.
Helpful Screen Shots
Hope this helps.