flintrocks / flint

The Flint Programming Language for Smart Contracts
MIT License
2 stars 0 forks source link

Constructors for external traits #104

Closed Aurel300 closed 5 years ago

Aurel300 commented 5 years ago

(From #73)

External contracts are pre-existing on the EVM blockchain, and localisable by a specific EVM address. Their interface may be specified in Flint code using external traits. To be able to interact with a given address using a given contract interface, there needs to be a way for the programmer to instantiate / construct an instance.

The constructor is never specified in the external trait, because it is not creating the contract (as in deploying a new one to the blockchain), but simply mapping an existing instance to a variable.

The implicit constructor has one argument, address, of type Address.

external trait Ext {
  func someFunc()
}

contract FlintContract {}

FlintContract :: (any) {
  public init() {
    let ext: Ext = Ext(address: 0xABCDABCD...)
    call! ext.someFunc()
  }
}