UNPKG

46.4 kBTypeScriptView Raw
1// tslint:disable
2/// <reference path="./global.d.ts" />
3
4/**
5 * Marks an interface or class as not implementable or extendable.
6 *
7 * Makes it an error to pass values that would otherwise match the shape of the interface.
8 *
9 * See the [Standard Library](https://neo-one.io/docs/smart-contract-basics#Opaque-Tag-Symbol) chapter of the main guide for more information.
10 */
11declare const OpaqueTagSymbol0: unique symbol;
12
13/**
14 * `Buffer` that represents a NEO address.
15 *
16 * Stored as a script hash (Hash160) internally.
17 *
18 * See the [Standard Library](https://neo-one.io/docs/smart-contract-basics#Value-Types) chapter of the main guide for more information.
19 */
20export const Address: AddressConstructor;
21export interface Address extends Buffer {
22 readonly [OpaqueTagSymbol0]: unique symbol;
23}
24export interface AddressConstructor {
25 /**
26 * Creates an `Address` from a literal string. Accepts either a NEO address or a script hash.
27 *
28 * @example
29 *
30 * const address = Address.from('ALq7AWrhAueN6mJNqk6FHJjnsEoPRytLdW');
31 *
32 * @example
33 *
34 * const address = Address.from('0xcef0c0fdcfe7838eff6ff104f9cdec2922297537');
35 *
36 * @param value Literal string for an `Address`.
37 * @returns `Address` for the specified `value`
38 */
39 readonly from: (value: string) => Address;
40 /**
41 * Verifies that the invocation was directly called AND approved by `Address`.
42 *
43 * Smart contracts should invoke this function before taking transferring items for `Address`es, like transferring tokens, that require the permission of the `Address`.
44 *
45 * @example
46 *
47 * if (!Address.isCaller(address)) {
48 * return false;
49 * }
50 *
51 * @returns true if `Address` approves this invocation.
52 */
53 readonly isCaller: (address: Address) => boolean;
54 /**
55 * Verifies that the `Transaction` was signed by the `address`.
56 *
57 * In most cases, smart contracts should instead use `Address.isCaller`.
58 *
59 * @example
60 *
61 * if (!Address.isSender(address)) {
62 * return false;
63 * }
64 *
65 * @returns true if `Address` signed this `Transaction`
66 */
67 readonly isSender: (address: Address) => boolean;
68 readonly [OpaqueTagSymbol0]: unique symbol;
69}
70
71/**
72 * `Buffer` that represents a NEO 256 bit hash.
73 *
74 * Examples of `Hash256` include `Block` hashes and `Transaction` hashes.
75 *
76 * See the [Standard Library](https://neo-one.io/docs/smart-contract-basics#Value-Types) chapter of the main guide for more information.
77 */
78export const Hash256: Hash256Constructor;
79export interface Hash256 extends Buffer {
80 readonly [OpaqueTagSymbol0]: unique symbol;
81}
82export interface Hash256Constructor {
83 /**
84 * Creates a `Hash256` from a literal string.
85 *
86 * @example
87 *
88 * const hash = Hash256.from('0xd6572a459b95d9136b7a713c5485ca709f9efa4f08f1c25dd792672d2bd75bfb');
89 *
90 * @param value Literal string for a `Hash256`.
91 * @returns `Hash256` for the specified `value`
92 */
93 readonly from: (value: string) => Hash256;
94 /**
95 * `Hash256` of the NEO `Asset`.
96 */
97 readonly NEO: Hash256;
98 /**
99 * `Hash256` of the GAS `Asset`.
100 */
101 readonly GAS: Hash256;
102 readonly [OpaqueTagSymbol0]: unique symbol;
103}
104
105/**
106 * `Buffer` that represents a public key.
107 *
108 * See the [Standard Library](https://neo-one.io/docs/smart-contract-basics#Value-Types) chapter of the main guide for more information.
109 */
110export const PublicKey: PublicKeyConstructor;
111export interface PublicKey extends Buffer {
112 readonly [OpaqueTagSymbol0]: unique symbol;
113}
114export interface PublicKeyConstructor {
115 /**
116 * Creates a `PublicKey` from a literal string.
117 *
118 * @example
119 *
120 * const publicKey = PublicKey.from('02028a99826edc0c97d18e22b6932373d908d323aa7f92656a77ec26e8861699ef');
121 *
122 * @param value Literal string for a `PublicKey`.
123 * @returns `PublicKey` for the specified `value`
124 */
125 readonly from: (value: string) => PublicKey;
126 readonly [OpaqueTagSymbol0]: unique symbol;
127}
128
129interface FixedTag<T extends number> {
130 readonly __decimals: T;
131}
132/**
133 * Integer which represents a number with the specified decimals.
134 *
135 * See the [Standard Library](https://neo-one.io/docs/smart-contract-basics#Tagged-Types) chapter of the main guide for more information.
136 */
137export type Fixed<Decimals extends number> = number | (number & FixedTag<Decimals>);
138/**
139 * Integer that represents a number with 0 decimals.
140 *
141 * See the [Standard Library](https://neo-one.io/docs/smart-contract-basics#Tagged-Types) chapter of the main guide for more information.
142 */
143export type Integer = Fixed<0>;
144/**
145 * Integer that represents a number with 8 decimals.
146 *
147 * See the [Standard Library](https://neo-one.io/docs/smart-contract-basics#Tagged-Types) chapter of the main guide for more information.
148 */
149export type Fixed8 = Fixed<8>;
150
151/**
152 * `Attribute` usage flag indicates the type of the data.
153 *
154 * @see BufferAttributeUsage
155 * @see PublicKeyAttributeUsage
156 * @see AddressAttributeUsage
157 * @see Hash256AttributeUsage
158 */
159export enum AttributeUsage {
160 ContractHash = 0x00,
161 ECDH02 = 0x02,
162 ECDH03 = 0x03,
163 Script = 0x20,
164 Vote = 0x30,
165 DescriptionUrl = 0x81,
166 Description = 0x90,
167 Hash1 = 0xa1,
168 Hash2 = 0xa2,
169 Hash3 = 0xa3,
170 Hash4 = 0xa4,
171 Hash5 = 0xa5,
172 Hash6 = 0xa6,
173 Hash7 = 0xa7,
174 Hash8 = 0xa8,
175 Hash9 = 0xa9,
176 Hash10 = 0xaa,
177 Hash11 = 0xab,
178 Hash12 = 0xac,
179 Hash13 = 0xad,
180 Hash14 = 0xae,
181 Hash15 = 0xaf,
182 Remark = 0xf0,
183 Remark1 = 0xf1,
184 Remark2 = 0xf2,
185 Remark3 = 0xf3,
186 Remark4 = 0xf4,
187 Remark5 = 0xf5,
188 Remark6 = 0xf6,
189 Remark7 = 0xf7,
190 Remark8 = 0xf8,
191 Remark9 = 0xf9,
192 Remark10 = 0xfa,
193 Remark11 = 0xfb,
194 Remark12 = 0xfc,
195 Remark13 = 0xfd,
196 Remark14 = 0xfe,
197 Remark15 = 0xff,
198}
199
200/**
201 * `Attribute` usage flag indicating the data is an arbitrary `Buffer`
202 *
203 * @see BufferAttribute
204 */
205export type BufferAttributeUsage =
206 | AttributeUsage.DescriptionUrl
207 | AttributeUsage.Description
208 | AttributeUsage.Remark
209 | AttributeUsage.Remark1
210 | AttributeUsage.Remark2
211 | AttributeUsage.Remark3
212 | AttributeUsage.Remark4
213 | AttributeUsage.Remark5
214 | AttributeUsage.Remark6
215 | AttributeUsage.Remark7
216 | AttributeUsage.Remark8
217 | AttributeUsage.Remark9
218 | AttributeUsage.Remark10
219 | AttributeUsage.Remark11
220 | AttributeUsage.Remark12
221 | AttributeUsage.Remark13
222 | AttributeUsage.Remark14
223 | AttributeUsage.Remark15;
224/**
225 * `Attribute` usage flag indicating the data is a `PublicKey`
226 *
227 * @see PublicKeyAttribute
228 */
229export type PublicKeyAttributeUsage = AttributeUsage.ECDH02 | AttributeUsage.ECDH03;
230/**
231 * `Attribute` usage flag indicating the data is an `Address`
232 *
233 * @see AddressAttribute
234 */
235export type AddressAttributeUsage = AttributeUsage.Script;
236/**
237 * `Attribute` usage flag indicating the data is a `Hash256`
238 *
239 * @see Hash256Attribute
240 */
241export type Hash256AttributeUsage =
242 | AttributeUsage.ContractHash
243 | AttributeUsage.Vote
244 | AttributeUsage.Hash1
245 | AttributeUsage.Hash2
246 | AttributeUsage.Hash3
247 | AttributeUsage.Hash4
248 | AttributeUsage.Hash5
249 | AttributeUsage.Hash6
250 | AttributeUsage.Hash7
251 | AttributeUsage.Hash8
252 | AttributeUsage.Hash9
253 | AttributeUsage.Hash10
254 | AttributeUsage.Hash11
255 | AttributeUsage.Hash12
256 | AttributeUsage.Hash13
257 | AttributeUsage.Hash14
258 | AttributeUsage.Hash15;
259
260/**
261 * Base interface for `Attribute`s
262 *
263 * @see Attribute
264 */
265export const AttributeBase: AttributeBaseConstructor;
266export interface AttributeBase {
267 readonly usage: AttributeUsage;
268 readonly data: Buffer;
269 readonly [OpaqueTagSymbol0]: unique symbol;
270}
271export interface AttributeBaseConstructor {
272 readonly [OpaqueTagSymbol0]: unique symbol;
273}
274
275/**
276 * `Attribute` whose data is an arbitrary `Buffer`.
277 */
278export interface BufferAttribute extends AttributeBase {
279 readonly usage: BufferAttributeUsage;
280 readonly data: Buffer;
281}
282/**
283 * `Attribute` whose data is a `PublicKey`.
284 */
285export interface PublicKeyAttribute extends AttributeBase {
286 readonly usage: PublicKeyAttributeUsage;
287 readonly data: PublicKey;
288}
289/**
290 * `Attribute` whose data is an `Address`.
291 */
292export interface AddressAttribute extends AttributeBase {
293 readonly usage: AddressAttributeUsage;
294 readonly data: Address;
295}
296/**
297 * `Attribute` whose data is a `Hash256`.
298 */
299export interface Hash256Attribute extends AttributeBase {
300 readonly usage: Hash256AttributeUsage;
301 readonly data: Hash256;
302}
303
304/**
305 * `Attribute`s are used to store additional data on `Transaction`s. Most `Attribute`s are used to store arbitrary data, whereas some, like `AddressAttribute`, have specific uses in the NEO
306 * protocol.
307 */
308export type Attribute = BufferAttribute | PublicKeyAttribute | AddressAttribute | Hash256Attribute;
309
310/**
311 * `Output`s represent the destination `Address` and amount transferred of a given `Asset`.
312 *
313 * The sum of the unspent `Output`s of an `Address` represent the total balance of the `Address`.
314 */
315export const Output: OutputConstructor;
316export interface Output {
317 /**
318 * Destination `Address`.
319 */
320 readonly address: Address;
321 /**
322 * `Hash256` of the `Asset` that was transferred.
323 */
324 readonly asset: Hash256;
325 /**
326 * Amount transferred.
327 */
328 readonly value: Fixed8;
329 readonly [OpaqueTagSymbol0]: unique symbol;
330}
331export interface OutputConstructor {
332 readonly [OpaqueTagSymbol0]: unique symbol;
333}
334
335/**
336 * `Input`s are a reference to an `Output` of a `Transaction` that has been persisted to the blockchain. The sum of the `value`s of the referenced `Output`s is the total amount transferred in the `Transaction`.
337 */
338export const Input: InputConstructor;
339export interface Input {
340 /**
341 * `Hash256` of the `Transaction` this input references.
342 */
343 readonly hash: Hash256;
344 /**
345 * `Output` index within the `Transaction` this input references.
346 */
347 readonly index: Integer;
348 readonly [OpaqueTagSymbol0]: unique symbol;
349}
350export interface InputConstructor {
351 readonly [OpaqueTagSymbol0]: unique symbol;
352}
353
354/**
355 * Constants that specify the type of a `Transaction`.
356 */
357export enum TransactionType {
358 /**
359 * First `Transaction` in each block which contains the `Block` rewards for the consensus node that produced the `Block`.
360 *
361 * @see MinerTransaction
362 */
363 Miner = 0x00,
364 /**
365 * Issues new currency of a first-class `Asset`.
366 *
367 * @see IssueTransaction
368 */
369 Issue = 0x01,
370 /**
371 * Claims GAS for a set of spent `Output`s.
372 *
373 * @see ClaimTransaction
374 */
375 Claim = 0x02,
376 /**
377 * Enrolls a new validator for a given `PublicKey`.
378 *
379 * @see EnrollmentTransaction
380 * @deprecated
381 */
382 Enrollment = 0x20,
383 /**
384 * Registers a new first class `Asset`
385 *
386 * @see RegisterTransaction
387 * @deprecated Replaced by `Client#registerAsset`
388 */
389 Register = 0x40,
390 /**
391 * Transfers first class `Asset`s
392 *
393 * @see ContractTransaction
394 */
395 Contract = 0x80,
396 State = 0x90,
397 /**
398 * Registers a new `Contract`
399 *
400 * @see PublishTransaction
401 * @deprecated Replaced by `Client#publish`
402 */
403 Publish = 0xd0,
404 /**
405 * Runs a script in the NEO VM.
406 *
407 * @see InvocationTransaction
408 */
409 Invocation = 0xd1,
410}
411
412/**
413 * Base interface for all `Transaction`s.
414 */
415export const TransactionBase: TransactionBaseConstructor;
416export interface TransactionBase {
417 /**
418 * `Hash256` of this `Transaction`.
419 */
420 readonly hash: Hash256;
421 /**
422 * Type of the `Transaction`.
423 *
424 * @see TransactionType
425 */
426 readonly type: TransactionType;
427 /**
428 * `Attribute`s attached to the `Transaction`.
429 *
430 * @see Attribute
431 */
432 readonly attributes: Attribute[];
433 /**
434 * `Output`s of the `Transaction`.
435 *
436 * @see Output
437 */
438 readonly outputs: Output[];
439 /**
440 * `Input`s of the `Transaction`.
441 *
442 * @see Input
443 */
444 readonly inputs: Input[];
445 /**
446 * Corresponding `Output`s for the `Input`s of the `Transaction`.
447 *
448 * @see Output
449 */
450 readonly references: Output[];
451 /**
452 * `Output`s which have not been spent.
453 *
454 * @see Output
455 */
456 readonly unspentOutputs: Output[];
457 readonly [OpaqueTagSymbol0]: unique symbol;
458}
459export interface TransactionBaseConstructor {}
460
461/**
462 * First `Transaction` in each `Block` which contains the `Block` rewards for the consensus node that produced the `Block`.
463 */
464export interface MinerTransaction extends TransactionBase {
465 readonly type: TransactionType.Miner;
466}
467/**
468 * Issues new currency of a first-class `Asset`.
469 */
470export interface IssueTransaction extends TransactionBase {
471 readonly type: TransactionType.Issue;
472}
473/**
474 * Claims GAS for a set of spent `Output`s.
475 */
476export interface ClaimTransaction extends TransactionBase {
477 readonly type: TransactionType.Claim;
478}
479/**
480 * Enrolls a new validator for a given `PublicKey`.
481 *
482 * @deprecated
483 */
484export interface EnrollmentTransaction extends TransactionBase {
485 readonly type: TransactionType.Enrollment;
486}
487/**
488 * Registers a new first class `Asset`.
489 *
490 * @deprecated Replaced by `Client#registerAsset`
491 */
492export interface RegisterTransaction extends TransactionBase {
493 readonly type: TransactionType.Register;
494}
495/**
496 * `Transaction` that transfers first class `Asset`s.
497 */
498export interface ContractTransaction extends TransactionBase {
499 readonly type: TransactionType.Contract;
500}
501/**
502 * Contains the state of votes.
503 */
504export interface StateTransaction extends TransactionBase {
505 readonly type: TransactionType.State;
506}
507/**
508 * Registers a new `Contract`
509 *
510 * @deprecated Replaced by `Client#publish`
511 */
512export interface PublishTransaction extends TransactionBase {
513 readonly type: TransactionType.Publish;
514}
515/**
516 * `Transaction` which runs a script in the NEO VM.
517 */
518export interface InvocationTransaction extends TransactionBase {
519 readonly type: TransactionType.Invocation;
520 /**
521 * Code that was executed in NEO VM.
522 */
523 readonly script: Buffer;
524}
525/**
526 * `Transaction`s are persisted to the blockchain and represent various functionality like transferring first class `Asset`s or executing smart contracts.
527 *
528 * Smart contracts are executed within an `InvocationTransaction`.
529 *
530 * @example
531 *
532 * const transactionHash = Hash256.from('0xd6572a459b95d9136b7a713c5485ca709f9efa4f08f1c25dd792672d2bd75bfb');
533 * const transaction = Transaction.for(transactionHash);
534 * const transactionOutputs = transaction.outputs;
535 *
536 */
537export const Transaction: TransactionConstructor;
538export type Transaction =
539 | MinerTransaction
540 | IssueTransaction
541 | ClaimTransaction
542 | EnrollmentTransaction
543 | RegisterTransaction
544 | ContractTransaction
545 | StateTransaction
546 | PublishTransaction
547 | InvocationTransaction;
548export interface TransactionConstructor {
549 /**
550 * @returns `Transaction` for the specified `hash`.
551 */
552 readonly for: (hash: Hash256) => Transaction;
553 readonly [OpaqueTagSymbol0]: unique symbol;
554}
555
556/**
557 * Balance and vote information for an `Address`.
558 *
559 * @example
560 *
561 * const address = Address.from('ALq7AWrhAueN6mJNqk6FHJjnsEoPRytLdW');
562 * const account = Account.for(address);
563 * const neoBalance = account.getBalance(Hash256.NEO);
564 *
565 */
566export const Account: AccountConstructor;
567export interface Account {
568 /**
569 * `Address` of this `Account`.
570 */
571 readonly address: Address;
572 /**
573 * Retrieve the balance for a first class `Asset` based on its `Hash256`.
574 */
575 readonly getBalance: (asset: Hash256) => Fixed8;
576 readonly [OpaqueTagSymbol0]: unique symbol;
577}
578export interface AccountConstructor {
579 /**
580 * @returns `Account` for the specified `address`.
581 */
582 readonly for: (address: Address) => Account;
583 readonly [OpaqueTagSymbol0]: unique symbol;
584}
585
586/**
587 * Constants that specify the type of the `Asset`.
588 */
589export enum AssetType {
590 Credit = 0x40,
591 Duty = 0x80,
592 /**
593 * Reserved for the NEO `Asset`.
594 */
595 Governing = 0x00,
596 /**
597 * Reserved for the GAS `Asset`.
598 */
599 Utility = 0x01,
600 Currency = 0x08,
601 Share = 0x90,
602 Invoice = 0x98,
603 Token = 0x60,
604}
605
606/**
607 * Attributes of a first class asset.
608 *
609 * Smart contract authors will typically only interact with the NEO and GAS `Asset`s.
610 *
611 * @example
612 *
613 * const asset = Asset.for(Hash256.NEO);
614 * const neoAmount = asset.amount;
615 *
616 */
617export const Asset: AssetConstructor;
618export interface Asset {
619 /**
620 * `Hash256` of this `Asset`.
621 */
622 readonly hash: Hash256;
623 /**
624 * `AssetType` of the `Asset`
625 *
626 * @see AssetType
627 */
628 readonly type: AssetType;
629 /**
630 * Total possible supply of the `Asset`
631 */
632 readonly amount: Fixed8;
633 /**
634 * Amount currently available of the `Asset`
635 */
636 readonly available: Fixed8;
637 /**
638 * Precision (number of decimal places) of the `Asset`
639 */
640 readonly precision: Integer;
641 /**
642 * Owner of the `Asset`.
643 */
644 readonly owner: PublicKey;
645 /**
646 * Admin of the `Asset`.
647 */
648 readonly admin: Address;
649 /**
650 * Issuer of the `Asset`.
651 */
652 readonly issuer: Address;
653 readonly [OpaqueTagSymbol0]: unique symbol;
654}
655export interface AssetConstructor {
656 /**
657 * @returns `Asset` for the specified `hash`.
658 */
659 readonly for: (hash: Hash256) => Asset;
660 readonly [OpaqueTagSymbol0]: unique symbol;
661}
662
663/**
664 * Attributes of a smart contract deployed to the blockchain.
665 *
666 * @example
667 *
668 * const contractAddress = Address.from('0xcef0c0fdcfe7838eff6ff104f9cdec2922297537');
669 * const contract = Contract.for(contractAddress);
670 * const contractScript = contract.script;
671 *
672 */
673export const Contract: ContractConstructor;
674export interface Contract {
675 /**
676 * `Contract` code.
677 */
678 readonly script: Buffer;
679 /**
680 * Flag that indicates if the `Contract` supports receiving `Asset`s.
681 */
682 readonly payable: boolean;
683 readonly [OpaqueTagSymbol0]: unique symbol;
684}
685export interface ContractConstructor {
686 /**
687 * Returns `undefined` if a `Contract` does not exist at `address`.
688 *
689 * @returns `Contract` for the specified `address`.
690 */
691 readonly for: (address: Address) => Contract | undefined;
692 readonly [OpaqueTagSymbol0]: unique symbol;
693}
694
695/**
696 * Attributes of a `Block` persisted to the blockchain. `Header` includes all information except the list of `Transaction`s.
697 *
698 * @example
699 *
700 * const blockHash = Hash256.from('0xd6572a459b95d9136b7a713c5485ca709f9efa4f08f1c25dd792672d2bd75bfb');
701 * const header = Header.for(blockHash);
702 *
703 */
704export const Header: HeaderConstructor;
705export interface Header {
706 /**
707 * `Block` hash.
708 */
709 readonly hash: Hash256;
710 /**
711 * NEO blockchain version.
712 */
713 readonly version: Integer;
714 /**
715 * Previous `Block` hash.
716 */
717 readonly previousHash: Hash256;
718 /**
719 * `Block` index.
720 */
721 readonly index: Integer;
722 /**
723 * Root of the `Transaction` hash Merkle Tree.
724 */
725 readonly merkleRoot: Hash256;
726 /**
727 * `Block` time persisted.
728 */
729 readonly time: Integer;
730 /**
731 * Next consensus address.
732 */
733 readonly nextConsensus: Address;
734 readonly [OpaqueTagSymbol0]: unique symbol;
735}
736export interface HeaderConstructor {
737 /**
738 * Accepts either the `Hash256` or the index of the `Block`.
739 *
740 * @returns `Header` for the specified `hashOrIndex`.
741 */
742 readonly for: (hashOrIndex: Hash256 | Integer) => Header;
743 readonly [OpaqueTagSymbol0]: unique symbol;
744}
745
746/**
747 * Attributes of a `Block` persisted to the blockchain.
748 *
749 * @example
750 *
751 * const genesisBlock = Block.for(0);
752 *
753 */
754export const Block: BlockConstructor;
755export interface Block extends Header {
756 /**
757 * `Transaction`s contained in the `Block`.
758 */
759 readonly transactions: Transaction[];
760}
761export interface BlockConstructor {
762 /**
763 * Accepts either the `Hash256` or the index of the `Block`.
764 *
765 * @returns `Block` for the specified `hashOrIndex`.
766 */
767 readonly for: (hashOrIndex: Hash256 | Integer) => Block;
768 readonly [OpaqueTagSymbol0]: unique symbol;
769}
770
771/**
772 * Value that can be used as a key in `MapStorage` and a value for `SetStorage`.
773 *
774 * See the [Properties and Storage](https://neo-one.io/docs/properties-and-storage) chapter of the main guide for more information.
775 */
776export type SerializableKeySingle = number | string | boolean | Buffer;
777type SK = SerializableKeySingle;
778export type SerializableKey = SK | [SK, SK] | [SK, SK, SK] | [SK, SK, SK, SK];
779export interface SerializableValueArray extends ReadonlyArray<SerializableValue> {}
780export interface SerializableValueMap extends ReadonlyMap<SerializableKeySingle, SerializableValue> {}
781export interface SerializableValueSet extends ReadonlySet<SerializableValue> {}
782export interface SerializableValueObject {
783 readonly [key: string]: SerializableValue;
784}
785/**
786 * Value that can be serialized for storage.
787 *
788 * See the [Properties and Storage](https://neo-one.io/docs/properties-and-storage) chapter of the main guide for more information.
789 */
790export type SerializableValue =
791 | undefined
792 | null
793 | number
794 | string
795 | boolean
796 | Buffer
797 | SerializableValueArray
798 | SerializableValueMap
799 | SerializableValueSet
800 | SerializableValueObject;
801
802/**
803 * Persistent smart contract array storage. Only usable as a `SmartContract` property.
804 *
805 * See the [Properties and Storage](https://neo-one.io/docs/properties-and-storage#Structured-Storage) chapter of the main guide for more information.
806 *
807 * @example
808 *
809 * class MySmartContract extends SmartContract {
810 * private readonly pendingAddresses =
811 * ArrayStorage.for<Address>();
812 *
813 * public addPendingAddress(address: Address): void {
814 * this.pendingAddresses.push(address);
815 * }
816 * }
817 *
818 */
819export const ArrayStorage: ArrayStorageConstructor;
820export interface ArrayStorage<T extends SerializableValue> extends Iterable<T> {
821 readonly [Symbol.iterator]: () => IterableIterator<T>;
822 /**
823 * Gets the length of the array. This is a number one higher than the highest element defined in an array.
824 */
825 readonly length: number;
826 /**
827 * Executes a provided function once per each value in storage.
828 * @param callback function to execute for each element.
829 * @returns `undefined`
830 */
831 readonly forEach: (callback: (value: T, idx: number) => void) => void;
832 /**
833 * Appends new elements to storage, and returns the new length of the array.
834 * @param items New elements to add.
835 */
836 readonly push: (...items: T[]) => number;
837 /**
838 * Removes the last element from an array and returns it.
839 */
840 readonly pop: () => T | undefined;
841 /**
842 * Access the value at index `n`.
843 */
844 [n: number]: T;
845 readonly [OpaqueTagSymbol0]: unique symbol;
846}
847export interface ArrayStorageConstructor {
848 /**
849 * Constructs a new `ArrayStorage` instance. Only usable as a `SmartContract` property.
850 */
851 for<T extends SerializableValue>(): ArrayStorage<T>;
852 readonly [OpaqueTagSymbol0]: unique symbol;
853}
854
855type SKMapAtTwo<K extends [SK, SK], V extends SerializableValue> = {
856 (prefix: K[0]): MapStorage<K[1], V>;
857};
858type SKMapAtThree<K extends [SK, SK, SK], V extends SerializableValue> = {
859 (prefix: K[0]): MapStorage<[K[1], K[2]], V>;
860 (prefix: [K[0], K[1]]): MapStorage<K[2], V>;
861};
862type SKMapAtFour<K extends [SK, SK, SK, SK], V extends SerializableValue> = {
863 (prefix: K[0]): MapStorage<[K[1], K[2], K[3]], V>;
864 (prefix: [K[0], K[1]]): MapStorage<[K[2], K[3]], V>;
865 (prefix: [K[0], K[1], K[2]]): MapStorage<K[3], V>;
866};
867
868/**
869 * Persistent smart contract storage. Only usable as a `SmartContract` property.
870 *
871 * See the [Properties and Storage](https://neo-one.io/docs/properties-and-storage#Structured-Storage) chapter of the main guide for more information.
872 *
873 * @example
874 *
875 * class Token extends SmartContract {
876 * private readonly balances =
877 * MapStorage.for<Address, Fixed<8>>();
878 *
879 * public transfer(
880 * from: Address,
881 * to: Address,
882 * amount: Fixed<8>,
883 * ): boolean {
884 * const fromBalance = this.balances.get(from);
885 * const toBalance = this.balances.get(to);
886 * this.balances.set(from, fromBalance - amount);
887 * this.balances.set(to, toBalance + amount);
888 * return true;
889 * }
890 * }
891 *
892 */
893export const MapStorage: MapStorageConstructor;
894export interface MapStorage<K extends SerializableKey, V extends SerializableValue> extends Iterable<[K, V]> {
895 readonly [Symbol.iterator]: () => IterableIterator<[K, V]>;
896 /**
897 * Executes a provided function once per each key/value pair in storage.
898 * @param callback function to execute for each element.
899 * @returns `undefined`
900 */
901 readonly forEach: (callback: (value: V, key: K) => void) => void;
902 /**
903 * Returns a specified element from storage.
904 * @param key the key of the element to return from storage.
905 * @returns the element associated with the specified key or undefined if the key can't be found in storage.
906 */
907 readonly get: (key: K) => V | undefined;
908 /**
909 * Returns a boolean indicating whether an element with the specified key exists or not.
910 * @param key the key of the element to test for presence in storage.
911 * @returns `true` if an element with the specified key exists in storage; otherwise `false`.
912 */
913 readonly has: (key: K) => boolean;
914 /**
915 * Removes the specified element from storage.
916 * @returns `true` if an element in storage existed and has been removed, or `false` if the element does not exist.
917 */
918 readonly delete: (key: K) => boolean;
919 /**
920 * Adds or updates an element with a specified key and value in storage.
921 * @param key The key of the element to add to storage.
922 * @param value The value of the element to add to storage.
923 * @returns the `MapStorage` object.
924 */
925 readonly set: (key: K, value: V) => MapStorage<K, V>;
926 /**
927 * Returns the elements from storage with the specified prefix.
928 * @param key The prefix key of desired elements from storage.
929 * @returns a `MapStorage` object representing the elements associated with the specified prefix.
930 */
931 readonly at: K extends [SK, SK]
932 ? SKMapAtTwo<K, V>
933 : K extends [SK, SK, SK]
934 ? SKMapAtThree<K, V>
935 : K extends [SK, SK, SK, SK]
936 ? SKMapAtFour<K, V>
937 : never;
938 readonly [OpaqueTagSymbol0]: unique symbol;
939}
940export interface MapStorageConstructor {
941 /**
942 * Constructs a new `MapStorage` instance. Only usable as a `SmartContract` property.
943 */
944 for<K extends SerializableKey, V extends SerializableValue>(): MapStorage<K, V>;
945 readonly [OpaqueTagSymbol0]: unique symbol;
946}
947
948type SKSetAtTwo<V extends [SK, SK]> = {
949 (prefix: V[0]): SetStorage<V[1]>;
950};
951type SKSetAtThree<V extends [SK, SK, SK]> = {
952 (prefix: V[0]): SetStorage<[V[1], V[2]]>;
953 (prefix: [V[0], V[1]]): SetStorage<V[2]>;
954};
955type SKSetAtFour<V extends [SK, SK, SK, SK]> = {
956 (prefix: V[0]): SetStorage<[V[1], V[2], V[3]]>;
957 (prefix: [V[0], V[1]]): SetStorage<[V[2], V[3]]>;
958 (prefix: [V[0], V[1], V[2]]): SetStorage<V[3]>;
959};
960
961/**
962 * Persistent smart contract set storage. Only usable as a `SmartContract` property.
963 *
964 * See the [Properties and Storage](https://neo-one.io/docs/properties-and-storage#Structured-Storage) chapter of the main guide for more information.
965 *
966 * @example
967 *
968 * class ICO extends SmartContract {
969 * private readonly whitelistedAddresses =
970 * SetStorage.for<Address>();
971 *
972 * public isWhitelisted(address: Address): boolean {
973 * return this.whitelistedAddresses.has(address);
974 * }
975 * }
976 *
977 */
978export const SetStorage: SetStorageConstructor;
979export interface SetStorage<V extends SerializableKey> extends Iterable<V> {
980 readonly [Symbol.iterator]: () => IterableIterator<V>;
981 /**
982 * Executes a provided function once per each value in storage.
983 * @param callback function to execute for each element.
984 * @returns `undefined`
985 */
986 readonly forEach: (callback: (value: V) => void) => void;
987 /**
988 * Returns a boolean indicating whether an element with the specified value exists or not.
989 * @param value the value to test for presence in storage.
990 * @returns `true` if an element with the specified value exists in storage; otherwise `false`.
991 */
992 readonly has: (value: V) => boolean;
993 /**
994 * Removes the specified element from storage.
995 * @returns `true` if an element in storage existed and has been removed, or `false` if the element does not exist.
996 */
997 readonly delete: (value: V) => boolean;
998 /**
999 * Adds an element with the specified value in storage.
1000 * @param value The value of the element to add to storage.
1001 * @returns the `SetStorage` object.
1002 */
1003 readonly add: (value: V) => SetStorage<V>;
1004 /**
1005 * Returns the elements from storage with the specified prefix.
1006 * @param key The prefix key of desired elements from storage.
1007 * @returns a `SetStorage` object representing the elements associated with the specified prefix.
1008 */
1009 readonly at: V extends [SK, SK]
1010 ? SKSetAtTwo<V>
1011 : V extends [SK, SK, SK]
1012 ? SKSetAtThree<V>
1013 : V extends [SK, SK, SK, SK]
1014 ? SKSetAtFour<V>
1015 : never;
1016 readonly [OpaqueTagSymbol0]: unique symbol;
1017}
1018export interface SetStorageConstructor {
1019 /**
1020 * Constructs a new `SetStorage` instance. Only usable as a `SmartContract` property.
1021 */
1022 for<K extends SerializableKey>(): SetStorage<K>;
1023 readonly [OpaqueTagSymbol0]: unique symbol;
1024}
1025
1026/**
1027 * Holds properties about the current state of the blockchain, the current `Transaction` and the current caller `Contract`.
1028 *
1029 * See the [Standard Library](https://neo-one.io/docs/standard-library#Blockchain-and-Transaction-Information) chapter of the main guide for more information.
1030 */
1031export interface BlockchainConstructor {
1032 /**
1033 * Time of the current `Block`.
1034 *
1035 * During execution, this is the timestamp of the `Block` that this `Transaction` will be included in.
1036 * During verification, this is the timestamp of the latest `Block` + 15 seconds which represents the earliest possible timestamp of the `Block` that this `Transaction` will be included in.
1037 */
1038 readonly currentBlockTime: number;
1039 /**
1040 * Index of the latest `Block` persisted to the blockchain.
1041 */
1042 readonly currentHeight: number;
1043 /**
1044 * `InvocationTransaction` this smart contract is executed in.
1045 */
1046 readonly currentTransaction: InvocationTransaction;
1047 /**
1048 * The `Address` of the smart contract that directly invoked the contract.
1049 *
1050 * Will be `undefined` if the smart contract method was not invoked by another smart contract, but instead was invoked by a user directly.
1051 */
1052 readonly currentCallerContract: Address | undefined;
1053 readonly [OpaqueTagSymbol0]: unique symbol;
1054}
1055/**
1056 * Information about the current state of the blockchain and the current execution.
1057 */
1058export const Blockchain: BlockchainConstructor;
1059
1060/**
1061 * Injects values at deployment time. Can only be used for default constructor parameters.
1062 */
1063export const Deploy: DeployConstructor;
1064export interface DeployConstructor {
1065 /**
1066 * Use the sender `Address` for the constructor parameter.
1067 *
1068 * @example
1069 * import { Address, Deploy, SmartContract } from '@neo-one/smart-contract';
1070 *
1071 * class Token extends SmartContract {
1072 * public constructor(public readonly owner: Address = Deploy.senderAddress) {
1073 * super();
1074 * }
1075 * }
1076 */
1077 readonly senderAddress: Address;
1078 readonly [OpaqueTagSymbol0]: unique symbol;
1079}
1080
1081/**
1082 * Creates an event notifier for `SmartContract` notifications.
1083 *
1084 * Must be explicitly typed and contain string literals for the event name and argument names.
1085 *
1086 * See the [Events and Logs](https://neo-one.io/docs/events-and-logs) chapter of the main guide for more information.
1087 *
1088 * @example
1089 *
1090 * const notifyTransfer = createEventNotifier<Address, Address, Fixed<8>>('transfer', 'from', 'to', 'amount');
1091 *
1092 * const from = Address.from('ALq7AWrhAueN6mJNqk6FHJjnsEoPRytLdW');
1093 * const to = Address.from('AVf4UGKevVrMR1j3UkPsuoYKSC4ocoAkKx');
1094 * notifyTransfer(from, to, 200);
1095 *
1096 * @param name Event name
1097 * @param argName Event argument name
1098 */
1099export function createEventNotifier<A0, A1, A2, A3, A4, A5>(
1100 name: string,
1101 arg0Name: string,
1102 arg1Name: string,
1103 arg2Name: string,
1104 arg3Name: string,
1105 arg4Name: string,
1106 arg5Name: string,
1107): (arg0: A0, arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => void;
1108export function createEventNotifier(name: string): () => void;
1109export function createEventNotifier<A0>(name: string, arg0Name: string): (arg0: A0) => void;
1110export function createEventNotifier<A0, A1>(
1111 name: string,
1112 arg0Name: string,
1113 arg1Name: string,
1114): (arg0: A0, arg1: A1) => void;
1115export function createEventNotifier<A0, A1, A2>(
1116 name: string,
1117 arg0Name: string,
1118 arg1Name: string,
1119 arg2Name: string,
1120): (arg0: A0, arg1: A1, arg2: A2) => void;
1121export function createEventNotifier<A0, A1, A2, A3>(
1122 name: string,
1123 arg0Name: string,
1124 arg1Name: string,
1125 arg2Name: string,
1126 arg3Name: string,
1127): (arg0: A0, arg1: A1, arg2: A2, arg3: A3) => void;
1128export function createEventNotifier<A0, A1, A2, A3, A4>(
1129 name: string,
1130 arg0Name: string,
1131 arg1Name: string,
1132 arg2Name: string,
1133 arg3Name: string,
1134 arg4Name: string,
1135): (arg0: A0, arg1: A1, arg2: A2, arg3: A3, arg4: A4) => void;
1136
1137/**
1138 * Declares an event for `SmartContract` notifications.
1139 *
1140 * Must be explicitly typed and contain string literals for the event name and argument names.
1141 *
1142 * See the [Events and Logs](https://neo-one.io/docs/events-and-logs) chapter of the main guide for more information.
1143 *
1144 * @example
1145 *
1146 * declareEvent<Address, Address, Fixed<8>>('transfer', 'from', 'to', 'amount');
1147 *
1148 * @param name Event name
1149 * @param argName Event argument name
1150 */
1151export function declareEvent<A0, A1, A2, A3, A4, A5>(
1152 name: string,
1153 arg0Name: string,
1154 arg1Name: string,
1155 arg2Name: string,
1156 arg3Name: string,
1157 arg4Name: string,
1158 arg5Name: string,
1159): void;
1160export function declareEvent(name: string): void;
1161export function declareEvent<A0>(name: string, arg0Name: string): void;
1162export function declareEvent<A0, A1>(name: string, arg0Name: string, arg1Name: string): void;
1163export function declareEvent<A0, A1, A2>(name: string, arg0Name: string, arg1Name: string, arg2Name: string): void;
1164export function declareEvent<A0, A1, A2, A3>(
1165 name: string,
1166 arg0Name: string,
1167 arg1Name: string,
1168 arg2Name: string,
1169 arg3Name: string,
1170): void;
1171export function declareEvent<A0, A1, A2, A3, A4>(
1172 name: string,
1173 arg0Name: string,
1174 arg1Name: string,
1175 arg2Name: string,
1176 arg3Name: string,
1177 arg4Name: string,
1178): void;
1179
1180/**
1181 * An opaque type that represents a method parameter which is typically forwarded as an argument to another smart contract.
1182 *
1183 * See the [Forward Values](https://neo-one.io/docs/forward-values) chapter of the advanced guide for more information.
1184 */
1185export const ForwardValue: ForwardValueConstructor;
1186export interface ForwardValue {
1187 readonly asString: () => string;
1188 readonly asStringNullable: () => string | undefined;
1189 readonly asNumber: () => number;
1190 readonly asNumberNullable: () => number | undefined;
1191 readonly asBoolean: () => boolean;
1192 readonly asBuffer: () => Buffer;
1193 readonly asBufferNullable: () => Buffer | undefined;
1194 readonly asAddress: () => Address;
1195 readonly asAddressNullable: () => Address | undefined;
1196 readonly asHash256: () => Hash256;
1197 readonly asHash256Nullable: () => Hash256 | undefined;
1198 readonly asPublicKey: () => PublicKey;
1199 readonly asPublicKeyNullable: () => PublicKey | undefined;
1200 readonly asArray: () => Array<ForwardValue>;
1201 readonly asArrayNullable: () => Array<ForwardValue> | undefined;
1202 readonly asMap: () => Map<ForwardValue, ForwardValue>;
1203 readonly asMapNullable: () => Map<ForwardValue, ForwardValue> | undefined;
1204 readonly [OpaqueTagSymbol0]: unique symbol;
1205}
1206export interface ForwardValueConstructor {
1207 readonly [OpaqueTagSymbol0]: unique symbol;
1208}
1209
1210interface ForwardedValueTag<T extends SmartContractArg> {}
1211/**
1212 * Marks a parameter or return type of a public `SmartContract` method as expecting a forwarded value.
1213 *
1214 * See the [Forward Values](https://neo-one.io/docs/forward-values) chapter of the advanced guide for more information.
1215 */
1216export type ForwardedValue<T extends SmartContractArg> = T | (T & ForwardedValueTag<T>);
1217
1218interface SmartContractValueArray extends Array<SmartContractValue> {}
1219interface SmartContractValueReadonlyArray extends ReadonlyArray<SmartContractValue> {}
1220interface SmartContractValueMap extends Map<SmartContractValue, SmartContractValue> {}
1221interface SmartContractValueReadonlyMap extends ReadonlyMap<SmartContractValue, SmartContractValue> {}
1222interface SmartContractValueObject {
1223 readonly [key: string]: SmartContractValue;
1224}
1225type SmartContractValue =
1226 | void
1227 | null
1228 | undefined
1229 | number
1230 | Fixed<any>
1231 | string
1232 | boolean
1233 | Buffer
1234 | Address
1235 | Hash256
1236 | PublicKey
1237 | SmartContractValueArray
1238 | SmartContractValueReadonlyArray
1239 | SmartContractValueMap
1240 | SmartContractValueReadonlyMap
1241 | SmartContractValueObject;
1242type SmartContractArg = SmartContractValue | ForwardValue;
1243type IsValidSmartContract<T> = {
1244 [K in keyof T]: T[K] extends Function
1245 ? Parameters<T[K]> extends SmartContractArg[]
1246 ? (ReturnType<T[K]> extends SmartContractArg ? T[K] : never)
1247 : never
1248 : T[K] extends SmartContractValue
1249 ? T[K]
1250 : never;
1251};
1252
1253/**
1254 * Object with string literals for the contract properties to be used in deployment.
1255 *
1256 * See the [Deployment](https://neo-one.io/docs/deployment#Properties) chapter of the main guide for more information.
1257 */
1258export interface ContractProperties {
1259 readonly codeVersion: string;
1260 readonly author: string;
1261 readonly email: string;
1262 readonly description: string;
1263}
1264
1265/**
1266 * Marks a class as a `SmartContract`.
1267 */
1268export class SmartContract {
1269 /**
1270 * Properties used for deployment of the `SmartContract`
1271 *
1272 * See the [Deployment](https://neo-one.io/docs/deployment#Properties) chapter of the main guide for more information.
1273 */
1274 public readonly properties: ContractProperties;
1275 /**
1276 * `Address` of the `SmartContract`.
1277 */
1278 public readonly address: Address;
1279 /**
1280 * Stores `Transaction` hashes that have been processed by a method marked with `@receive`, `@send`, or `@sendUnsafe`.
1281 *
1282 * Used to enforce that a `Transaction` with native `Asset`s is only ever processed once by an appropriate `@receive`, `@send`, or `@sendUnsafe` method.
1283 *
1284 * Unprocessed transactions that sent assets to the smart contract can be refunded by using `refundAssets`.
1285 *
1286 * See the [Native Assets](https://neo-one.io/docs/native-assets) chapter of the advanced guide for more information.
1287 */
1288 protected readonly processedTransactions: SetStorage<Hash256>;
1289 /**
1290 * Stores `Transaction` hashes that have been claimed by an address with a method marked with `@send`.
1291 *
1292 * The first contract output of a claimed transaction may be sent to the receiver by using `completeSend`.
1293 *
1294 * See the [Native Assets](https://neo-one.io/docs/native-assets) chapter of the advanced guide for more information.
1295 */
1296 protected readonly claimedTransactions: MapStorage<Hash256, Address>;
1297 /**
1298 * Property primarily used internally to validate that the smart contract is deployed only once.
1299 */
1300 protected readonly deployed: true;
1301 /**
1302 * Override to validate a contract upgrade invocation. Returns `false` by default. Return `true` to indicate the upgrade may proceed.
1303 *
1304 * See the [Deployment](https://neo-one.io/docs/deployment#Upgrade) chapter of the main guide for more information.
1305 *
1306 * @example
1307 *
1308 * export class Contract extends SmartContract {
1309 * public constructor(private readonly owner = Deploy.senderAddress) {
1310 * super();
1311 * }
1312 *
1313 * protected approveUpgrade(): boolean {
1314 * return Address.isCaller(this.owner);
1315 * }
1316 * }
1317 */
1318 protected approveUpgrade(): boolean;
1319 /**
1320 * Permanently deletes the contract.
1321 *
1322 * See the [Deployment](https://neo-one.io/docs/deployment#Destroy) chapter of the main guide for more information.
1323 */
1324 protected readonly destroy: () => void;
1325 /**
1326 * Method automatically added for refunding native `Asset`s.
1327 *
1328 * See the [Native Assets](https://neo-one.io/docs/native-assets) chapter of the advanced guide for more information.
1329 */
1330 public readonly refundAssets: () => boolean;
1331 /**
1332 * Method automatically added for sending native `Asset`s that have been claimed by a `@send` method.
1333 *
1334 * See the [Native Assets](https://neo-one.io/docs/native-assets) chapter of the advanced guide for more information.
1335 */
1336 public readonly completeSend: () => boolean;
1337 /**
1338 * Used internally by client APIs to upgrade the contract. Control whether an invocation is allowed to upgrade the contract by overriding `approveUpgrade`.
1339 *
1340 * See the [Deployment](https://neo-one.io/docs/deployment#Upgrade) chapter of the main guide for more information.
1341 */
1342 public readonly upgrade: (
1343 script: Buffer,
1344 parameterList: Buffer,
1345 returnType: number,
1346 properties: number,
1347 contractName: string,
1348 codeVersion: string,
1349 author: string,
1350 email: string,
1351 description: string,
1352 ) => boolean;
1353 /**
1354 * Returns the singleton instance of the `SmartContract` defined by the interface `T` at `address`.
1355 *
1356 * `T` is checked for validity and `SmartContract.for` will report an error during compilation if the interface is invalid.
1357 *
1358 * See the [Calling Smart Contracts](https://neo-one.io/docs/calling-smart-contracts) chapter of the main guide for more information.
1359 *
1360 * @example
1361 *
1362 * interface Token {
1363 * readonly transfer: (from: Address, to: Address, amount: Fixed<8>) => boolean;
1364 * }
1365 *
1366 * const address = Address.from('ALfnhLg7rUyL6Jr98bzzoxz5J7m64fbR4s');
1367 * const contract = SmartContract.for<Token>(address);
1368 *
1369 */
1370 public static readonly for: <T>(address: T extends IsValidSmartContract<T> ? Address : never) => T;
1371}
1372
1373export interface LinkedSmartContractConstructor {
1374 /**
1375 * Returns the singleton instance of the statically linked contract `T`.
1376 *
1377 * `T` is checked for validity and `LinkedSmartContract.for` will report an error during compilation if the interface is invalid.
1378 *
1379 * See the [Calling Smart Contracts](https://neo-one.io/docs/calling-smart-contracts) chapter of the main guide for more information.
1380 *
1381 * @example
1382 *
1383 * import { Token } from './Token';
1384 *
1385 * const contract = LinkedSmartContract.for<Token>();
1386 * const from = Address.from('ALfnhLg7rUyL6Jr98bzzoxz5J7m64fbR4s');
1387 * const to = Address.from('AVf4UGKevVrMR1j3UkPsuoYKSC4ocoAkKx');
1388 * contract.transfer(from, to, 10);
1389 *
1390 * @returns an object representing the underlying smart contract
1391 */
1392 readonly for: <T extends SmartContract>() => T extends IsValidSmartContract<T> ? T : never;
1393 readonly [OpaqueTagSymbol0]: unique symbol;
1394}
1395export const LinkedSmartContract: LinkedSmartContractConstructor;
1396
1397/**
1398 * Types that can be hashed the various `crypto` functions.
1399 *
1400 * @see crypto
1401 */
1402export type Hashable = number | string | boolean | Buffer;
1403/**
1404 * Contains various cryptography functions.
1405 */
1406export interface CryptoConstructor {
1407 /**
1408 * Returns a `Buffer` of the SHA1 hash of the input
1409 */
1410 readonly sha1: (value: Hashable) => Buffer;
1411 /**
1412 * Returns a `Buffer` of the SHA256 hash of the input
1413 */
1414 readonly sha256: (value: Hashable) => Buffer;
1415 /**
1416 * Returns a `Buffer` of the RMD160 hash of the SHA256 hash of the input.
1417 */
1418 readonly hash160: (value: Hashable) => Buffer;
1419 /**
1420 * Returns a `Buffer` of the SHA256 hash of the SHA256 hash of the input.
1421 */
1422 readonly hash256: (value: Hashable) => Buffer;
1423}
1424/**
1425 * Contains various cryptography functions.
1426 */
1427export const crypto: CryptoConstructor;
1428
1429/**
1430 * Represents a native `Asset` transfer.
1431 */
1432export interface Transfer {
1433 /**
1434 * The amount transferred.
1435 */
1436 readonly amount: Fixed<8>;
1437 /**
1438 * The `Hash256` of the `Asset` transferred.
1439 */
1440 readonly asset: Hash256;
1441 /**
1442 * The desination `Address` of the transfer.
1443 */
1444 readonly to: Address;
1445}
1446
1447/**
1448 * Marks a `SmartContract` method that verifies `Asset` transfers from the `SmartContract`.
1449 *
1450 * Method must return a boolean indicating whether the `SmartContract` wishes to approve sending the transferred `Asset`s.
1451 *
1452 * Method can take the `Transfer` as the final argument.
1453 *
1454 * See the [Native Assets](https://neo-one.io/docs/native-assets) chapter of the advanced guide for more information.
1455 *
1456 * @example
1457 *
1458 * export class Contract extends SmartContract {
1459 * `@send`
1460 * public withdraw(arg0: Address, arg1: Fixed<8>, transfer: Transfer): boolean {
1461 * // Don't allow sending anything but NEO
1462 * if (!transfer.asset.equals(Hash256.NEO)) {
1463 * return false;
1464 * }
1465 * // Do some additional checks on the transfer.to and transfer.amount being sent and other arguments.
1466 * return true;
1467 * }
1468 * }
1469 *
1470 */
1471export function send(target: any, propertyKey: string, descriptor: PropertyDescriptor): void;
1472/**
1473 * Marks a `SmartContract` method that verifies `Asset` transfers from the `SmartContract`.
1474 *
1475 * Method must return a boolean indicating whether the `SmartContract` wishes to approve sending the transferred `Asset`s.
1476 *
1477 * Note that unlike `@send`, `@sendUnsafe` does not use a two-phase send. Smart contract authors must implement their own logic for safely sending assets from the contract.
1478 *
1479 * May be used in combination with `@receive`.
1480 *
1481 * See the [Native Assets](https://neo-one.io/docs/native-assets) chapter of the advanced guide for more information.
1482 */
1483export function sendUnsafe(target: any, propertyKey: string, descriptor: PropertyDescriptor): void;
1484/**
1485 * Marks a `SmartContract` method that verifies receiving `Asset`s to the `SmartContract`.
1486 *
1487 * Method must return a boolean indicating whether the `SmartContract` wishes to receive the transferred `Asset`s.
1488 *
1489 * May be used in combination with `@sendUnsafe`.
1490 *
1491 * See the [Native Assets](https://neo-one.io/docs/native-assets) chapter of the advanced guide for more information.
1492 */
1493export function receive(target: any, propertyKey: string, descriptor: PropertyDescriptor): void;
1494/**
1495 * Marks a `SmartContract` method that verifies GAS claims from the `SmartContract`.
1496 *
1497 * Method must return a boolean indicating whether the `SmartContract` wishes to allow GAS to be claimed.
1498 *
1499 * May optionally take the `ClaimTransaction` this `SmartContract` is executed in as the last argument. Accessing `Blockchain.currentTransaction` will result in an error.
1500 *
1501 * See the [Native Assets](https://neo-one.io/docs/native-assets) chapter of the advanced guide for more information.
1502 */
1503export function claim(target: any, propertyKey: string, descriptor: PropertyDescriptor): void;
1504/**
1505 * Marks a `SmartContract` method as not modifying storage.
1506 *
1507 * See the [Methods](https://neo-one.io/docs/methods) chapter of the main guide for more information.
1508 */
1509export function constant(target: any, propertyKey: string, descriptor: PropertyDescriptor): void;