1

I'm new to this and I have a question regarding the following case:

suppose I defined and deployed a coin A, so coin A publicly exists in the network. Now suppose there is another contract called "conference", and it requires coin A (instead of ether) to buy a ticket. I do have some balance in A's mapping(address --> uint) balance, then given the fact that A is already deployed, how can I send some amount of coin A to conference contract address?

I'm confused since I only know how to send ether by calling address.send(contract_address). Is there a programmatic way for self-defined currency? Thanks.

I know a indirect way to do that: I transfer some amount of A of my account to the conference address by calling A.transferFrom(myaddress, conference), then upon receiving the transaction, the conference organizer calls conference.updateBalance(myaddress, 1).

But is there a direct way to achieve that? i.e. I call conference.buy(uint amount), both balance in A's contract and conference's contract get updated.

Thanks a lot for the help.

1

Some tokens support approveAndCall function. Where the contract is authorized to transfer an amount of tokens from the sender account, and the method receiveApproval is called immediately in the receiving contract where the transfer can be done.

There's a new proposal know as ERC223, that defines the method tokenFallback will be called to complete the transference.

I've seen several ICOs use approveAndCall, ER223 is pretty new and still under review. This is still a work in progress.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.