Best way is to do something like this:
local transform_id = 2659
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
item:transform(transform_id)
item:decay()
return true
end
Then in items.xml you set a decayTo and duration on the item it transformed into that...