The Javascript-API/geth wiki pages state that the at([address])
function does the following:
// initiate contract for an address
var myContractInstance = MyContract.at('0x78e97bcc5b5dd9ed228fed7a4887c0d7287344a9');
1. What does "instantiate by address" mean here?
2. What is going on when at
is called?
3. Should the address parameter be from an already deployed contract,
or a new address? _
4. What should be returned?
When I've been using at(..)
from a geth console attached to testrpc, it returns undefined
. Should this be the case? For example following the example in this question with 'testrpc' set up like this:
testrpc -a 1000
geth attach rpc:http://localhost:8545
EDIT:
Note, I think I've found the source code:
/**
* Should be called to get access to existing contract on a blockchain
*
* @method at
* @param {Address} contract address (required)
* @param {Function} callback {optional)
* @returns {Contract} returns contract if no callback was passed,
* otherwise calls callback function (err, contract)
*/
ContractFactory.prototype.at = function (address, callback) {
var contract = new Contract(this.eth, this.abi, address);
// this functions are not part of prototype,
// because we dont want to spoil the interface
addFunctionsToContract(contract);
addEventsToContract(contract);
if (callback) {
callback(null, contract);
}
return contract;
};
/**
* Should be called to create new contract instance
*
* @method Contract
* @param {Array} abi
* @param {Address} contract address
*/
var Contract = function (eth, abi, address) {
this._eth = eth;
this.transactionHash = null;
this.address = address;
this.abi = abi;
};