Skip to main content

Take allowed Funds

After having allowed Move objects, you can take the ones you need.

Example Code

The following example will take the Object which was allowed in the allow how-to guide.

Create the ISCAssets

First, you need to recreate the ISCAssets with the ObjectID.

IotaObjectID[] memory IotaObjectIDs = new IotaObjectID[](1);
IotaObjectIDs[0] = IotaObjectID.wrap(_allowanceIotaObjectID);
ISCAssets memory assets;
assets.objects = IotaObjectIDs;

Call takeAllowedFunds()

After that, you can call takeAllowedFunds() to take the allowance of the specified address/contract

ISC.sandbox.takeAllowedFunds(_address, ObjectID);

Full Example Code

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "@iota/iscmagic/ISC.sol";

contract allowance {
function takeAllowedFunds(address _address, bytes32 ObjectID) {
IotaObjectID[] memory IotaObjectIDs = new IotaObjectID[](1);
IotaObjectIDs[0] = IotaObjectID.wrap(_allowanceIotaObjectID);
ISCAssets memory assets;
assets.objects = IotaObjectIDs;
ISC.sandbox.takeAllowedFunds(_address, ObjectID);
}
}