Skip to main content
deleted 5 characters in body
Source Link

EDIT:

The new version (dawn-v4.0.0) improved the permissions system which totally makes sense. Now, ifIf you want to do a eosio.token::transfer from your contract you need to add a specific permission for that. Check this:

https://github.com/EOSIO/eos/issues/3013

As Dan said you need to add a permission like this:

cleos set account permission your_account active '{"threshold": 1,"keys": [{"key": "EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4","weight": 1}],"accounts": [{"permission":{"actor":"your_contract","permission":"eosio.code"},"weight":1}]}' owner -p your_account

Then you can still use:

     action(
        permission_level{ from, N(active) },
        N(eosio.token), N(transfer),
        std::make_tuple(from, _self, quantity, std::string(""))
     ).send();

And it totally makes sense because you don't want applications transferring your tokens without your consent. So, by the time that I answered this I didn't know that and I just suggested the use of INLINE_ACTION_SENDER because I saw it on the system bandwith routines and thought that it changed, but it's not true. Please stick with the regular action.send you just need a permission.

Although, if you want to follow the best practices for the eosio.token::transfer check this answer:

https://eosio.stackexchange.com/a/361/54

You need to "listen" the transfer for your contract and have a balance control for your users, so you can use their tokens for whatever action you need!

OLD WRONG ANSER:

Did you try the INLINE_ACTION_SENDER already? You need the permission of the lender of course.

INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {payer,N(active)},
                                                 { payer, N(eosio), quant, std::string("buy ram") } );

There's no way to execute an action with different permission than the one that you have from the current action. Maybe _self works but I don't think so.

EDIT:

The new version (dawn-v4.0.0) improved the permissions system which totally makes sense. Now, if you want to do a eosio.token::transfer from your contract you need to add a specific permission for that. Check this:

https://github.com/EOSIO/eos/issues/3013

As Dan said you need to add a permission like this:

cleos set account permission your_account active '{"threshold": 1,"keys": [{"key": "EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4","weight": 1}],"accounts": [{"permission":{"actor":"your_contract","permission":"eosio.code"},"weight":1}]}' owner -p your_account

Then you can still use:

     action(
        permission_level{ from, N(active) },
        N(eosio.token), N(transfer),
        std::make_tuple(from, _self, quantity, std::string(""))
     ).send();

And it totally makes sense because you don't want applications transferring your tokens without your consent. So, by the time that I answered this I didn't know that and I just suggested the use of INLINE_ACTION_SENDER because I saw it on the system bandwith routines and thought that it changed, but it's not true. Please stick with the regular action.send you just need a permission.

Although, if you want to follow the best practices for the eosio.token::transfer check this answer:

https://eosio.stackexchange.com/a/361/54

You need to "listen" the transfer for your contract and have a balance control for your users, so you can use their tokens for whatever action you need!

OLD WRONG ANSER:

Did you try the INLINE_ACTION_SENDER already? You need the permission of the lender of course.

INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {payer,N(active)},
                                                 { payer, N(eosio), quant, std::string("buy ram") } );

There's no way to execute an action with different permission than the one that you have from the current action. Maybe _self works but I don't think so.

EDIT:

The new version (dawn-v4.0.0) improved the permissions system which totally makes sense. If you want to do a eosio.token::transfer from your contract you need to add a specific permission for that. Check this:

https://github.com/EOSIO/eos/issues/3013

As Dan said you need to add a permission like this:

cleos set account permission your_account active '{"threshold": 1,"keys": [{"key": "EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4","weight": 1}],"accounts": [{"permission":{"actor":"your_contract","permission":"eosio.code"},"weight":1}]}' owner -p your_account

Then you can still use:

     action(
        permission_level{ from, N(active) },
        N(eosio.token), N(transfer),
        std::make_tuple(from, _self, quantity, std::string(""))
     ).send();

And it totally makes sense because you don't want applications transferring your tokens without your consent. So, by the time that I answered this I didn't know that and I just suggested the use of INLINE_ACTION_SENDER because I saw it on the system bandwith routines and thought that it changed, but it's not true. Please stick with the regular action.send you just need a permission.

Although, if you want to follow the best practices for the eosio.token::transfer check this answer:

https://eosio.stackexchange.com/a/361/54

You need to "listen" the transfer for your contract and have a balance control for your users, so you can use their tokens for whatever action you need!

OLD WRONG ANSER:

Did you try the INLINE_ACTION_SENDER already? You need the permission of the lender of course.

INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {payer,N(active)},
                                                 { payer, N(eosio), quant, std::string("buy ram") } );

There's no way to execute an action with different permission than the one that you have from the current action. Maybe _self works but I don't think so.

I was wrong in my first answer so I'm adjusting here with correct information.
Source Link

EDIT:

The new version (dawn-v4.0.0) improved the permissions system which totally makes sense. Now, if you want to do a eosio.token::transfer from your contract you need to add a specific permission for that. Check this:

https://github.com/EOSIO/eos/issues/3013

As Dan said you need to add a permission like this:

cleos set account permission your_account active '{"threshold": 1,"keys": [{"key": "EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4","weight": 1}],"accounts": [{"permission":{"actor":"your_contract","permission":"eosio.code"},"weight":1}]}' owner -p your_account

Then you can still use:

     action(
        permission_level{ from, N(active) },
        N(eosio.token), N(transfer),
        std::make_tuple(from, _self, quantity, std::string(""))
     ).send();

And it totally makes sense because you don't want applications transferring your tokens without your consent. So, by the time that I answered this I didn't know that and I just suggested the use of INLINE_ACTION_SENDER because I saw it on the system bandwith routines and thought that it changed, but it's not true. Please stick with the regular action.send you just need a permission.

Although, if you want to follow the best practices for the eosio.token::transfer check this answer:

https://eosio.stackexchange.com/a/361/54

You need to "listen" the transfer for your contract and have a balance control for your users, so you can use their tokens for whatever action you need!

OLD WRONG ANSER:

Did you try the INLINE_ACTION_SENDER already? You need the permission of the lender of course.

INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {payer,N(active)},
                                                 { payer, N(eosio), quant, std::string("buy ram") } );

There's no way to execute an action with different permission than the one that you have from the current action. Maybe _self works but I don't think so.

Did you try the INLINE_ACTION_SENDER already? You need the permission of the lender of course.

INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {payer,N(active)},
                                                 { payer, N(eosio), quant, std::string("buy ram") } );

There's no way to execute an action with different permission than the one that you have from the current action. Maybe _self works but I don't think so.

EDIT:

The new version (dawn-v4.0.0) improved the permissions system which totally makes sense. Now, if you want to do a eosio.token::transfer from your contract you need to add a specific permission for that. Check this:

https://github.com/EOSIO/eos/issues/3013

As Dan said you need to add a permission like this:

cleos set account permission your_account active '{"threshold": 1,"keys": [{"key": "EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4","weight": 1}],"accounts": [{"permission":{"actor":"your_contract","permission":"eosio.code"},"weight":1}]}' owner -p your_account

Then you can still use:

     action(
        permission_level{ from, N(active) },
        N(eosio.token), N(transfer),
        std::make_tuple(from, _self, quantity, std::string(""))
     ).send();

And it totally makes sense because you don't want applications transferring your tokens without your consent. So, by the time that I answered this I didn't know that and I just suggested the use of INLINE_ACTION_SENDER because I saw it on the system bandwith routines and thought that it changed, but it's not true. Please stick with the regular action.send you just need a permission.

Although, if you want to follow the best practices for the eosio.token::transfer check this answer:

https://eosio.stackexchange.com/a/361/54

You need to "listen" the transfer for your contract and have a balance control for your users, so you can use their tokens for whatever action you need!

OLD WRONG ANSER:

Did you try the INLINE_ACTION_SENDER already? You need the permission of the lender of course.

INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {payer,N(active)},
                                                 { payer, N(eosio), quant, std::string("buy ram") } );

There's no way to execute an action with different permission than the one that you have from the current action. Maybe _self works but I don't think so.

Source Link

Did you try the INLINE_ACTION_SENDER already? You need the permission of the lender of course.

INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {payer,N(active)},
                                                 { payer, N(eosio), quant, std::string("buy ram") } );

There's no way to execute an action with different permission than the one that you have from the current action. Maybe _self works but I don't think so.