Spedn is a high level smart contracts language for Bitcoin Cash. A new major version 0.2 has just been released.
This is 15th Nov 2019 hard-fork compatibility update with a bunch of changes and new features.
- Introducing an array type with syntax
[type; length], for example[Sig; 3] signatures, [byte; 10] message. The compiler type-checks the lengths so for example a type ofmessage . messageexpression will be inferred as[byte; 20]. - Syntax for tuple assignment now allows its items to be of different type:
(int a, Sig b, PubKey c) = expr; - Array elements can be accessed with
x[i]syntax. - Introducing a
bittype. In practice only arrays of bits are useful, as they represent a type ofcheckbitsargument in thecheckMultiSigfunction which was upgraded for Schnorr support. Bit array literal is also introduced, ex.[bit; 5] checkbits = 0b00110. - As mentioned -
checkMultiSigaccepts an additionalcheckbitsargument, as described in Nov 15 hard-fork spec. - For a byte array of unknown size there is
[byte]type which replaces the formerbintype. - Introducing (UTF-8) string literals, ex.
[byte] message = "Hello, World";. - Introducing custom type declarations (type aliases) which can be placed before contract declarations and then used as any other type in the contract. Ex.
type Message = [byte; 10];. Actually,Sig,DataSig,PubKey,Ripemd160,Sha1,Sha256,TimeandTimeSpanare defined internally as aliases. - Introducing
separator;statement that compiles toOP_CODESEPARATOR. - Introducing
fail;statement that compiles toOP_RETURN. - Introducing
checkSize(x)function that returnstrueif the runtime size of a byte array matches the declared type. - Variable names can now contain underscores, ex.
[byte] my_string.
For developers of v0.1 there's a short migration guide which shows how to adjust an old contract code to the new syntax.
No comments:
Post a Comment