@send

Decorator
Marks a SmartContract method that verifies Asset transfers from the SmartContract. Method must return a boolean indicating whether the SmartContract wishes to approve sending the transferred Assets. Method can take the Transfer as the final argument. See the Native Assets chapter of the advanced guide for more information.
export function send(target: any, propertyKey: string, descriptor: PropertyDescriptor): void; 

Example

export class Contract extends SmartContract { 
 @send 
 public withdraw(arg0: Address, arg1: Fixed<8>, transfer: Transfer): boolean { 
   // Don't allow sending anything but NEO 
   if (!transfer.asset.equals(Hash256.NEO)) { 
     return false; 
   } 
   // Do some additional checks on the transfer.to and transfer.amount being sent and other arguments. 
   return true; 
 } 
} 
  • @neo-one/client
  • @neo-one/smart-contract
DOCS
InstallationMain ConceptsAdvanced GuidesAPI ReferenceContributing
CHANNELS
GitHubStack OverflowDiscord ChatTwitterYouTube
COPYRIGHT © 2021 NEO•ONE