implement gen contract with inherit tree