기본요소 :
Int형 : Tact의 int는 257비트 +-정수
Bool형 : true, false(0,1) 다들 알죠 ?
Slice : 특정 부분 참조
Cell : 블록체인의 structure은 머클트리 형태인데 tree 속한 노드를 cell이라고 한다. 그 cell을 지칭할 때 사용
Builder : cell을 구축할때 사용(아래 예시 참조)
String : 문자열 선언
StringBuilder : string과 비슷하지만, 메모리 사용량 감소, 성능 개선을 위해 사용
map<key(int, address), value(int, cell, address, bool)> : key,value값을 지정할 수 있음.
build(): Cell {
return new Cell(this.data);
}
}
struct Point {
x: Int;
y: Int;
}
message SetValue {
key: Int;
value: Int?; // Optional
}
contract HelloWorld {
counter: Int;
init() {
self.counter = 0;
}
receive("increment") {
self.counter = self.counter + 1;
}
get fun counter(): Int {
return self.counter;
}
}
trait Ownable {
owner: Address;
fun requireOwner() {
nativeThrowUnless(132, context().sender == self.owner);
}
get fun owner(): Address {
return self.owner;
}
}
and it will use it contract ↓
contract Treasure with Ownable {
owner: Address; // Field from trait MUST be defined in contract itself
// Here we init the way we need, trait can't specify how you must init owner field
init(owner: Address) {
self.owner = owner;
}
}
참조 : Tact Documentation