Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Improved Transaction Sender Verification and First Class Assets #1051
In order to address verification of ownership via transaction sender or origin, we want to provide the following.
1. First Class Assets
Provide two new “define” primitives:
;; fungible assets (tokens) do not require a key type -- they are just maps ;; of accounts to balances (define-token foo-tokens) ;; defining non-fungible assets requires providing a "key type" which will be used to ;; uniquely identify the asset (define-asset bar-nfts int)
Then, we have some getters/setters:
(transfer-token! token-name amount from to) (transfer-asset! asset-name identifier from to) ;; returns balance of fungible tokens or the count of non-fungible assets (get-balance asset-name owner) ;; returns owner of non-fungible asset, type check error if applied to fungible tokens (get-owner asset-name identifier)
Then, we include in the wire format a set of allowed spends in the transaction. This makes it so that the limit is set outside of the context of the contract execution, and also forces wallet clients to participate in the security measure. The transaction aborts if the allowed spends are exceeded (though, it should be noted, transaction fees would be deducted).
2. Expressing general ownership verification
For general purpose ownership checks, we'll give contracts access to two variables: