0

I am studying Smart Contract with solidity. I can't understand something, so I want to get expert advice.

I logged in to the Upbit exchange to trade the golem's token. The Upbit exchange gave me a token deposit address. That address was a contract address(0x27c6769A0549fa03DafEd89d555C7E71B21Dd35E)

After depositing the golem's token, something happened that I could not understand. There is no ether to pay for the gas at the deposit address, but the golem's token was transferred to another address.

Q1] To transfer tokens without Ether, how to implement smart contract?

Q2] If you know where to find the sample code to reference, I would like to know the url

0

Q1

There's no way to transfer anything without gas (Ether). Also as contracts can't do anything 'on their own' but someone has to initialize each action, most likely this is what happened:

1) You transfer tokens to the contract

2) The contract transfers them onwards somewhere

3) You pay for both transfers

Q2

For the code, I don't have a deployed version to show you but it could be something like this:

pragma solidity ^0.4.22;

contract GolemToken {
    function transfer(address to, uint tokens) public returns (bool success);
}

// 0x27c6769a0549fa03dafed89d555c7e71b21dd35e
contract ExchangeContract {

    function transfer(address to, uint tokens) public returns (bool success) {
        address golemTokenContract = 0x00;
        address forwardAddress = 0x01;
        GolemToken gt = GolemToken(golemTokenContract);
        // Instead of transferring to 'to', transfer elsewhere
        gt.transfer(forwardAddress, tokens);
    }
}

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.