# Is this the right way to create abstract contract for inheritiance?

**URL:** <https://forum.fuel.network/t/is-this-the-right-way-to-create-abstract-contract-for-inheritiance/7350>\
**Category:** Sway\
**Created:** [December 13, 2024, 9:19am UTC](https://forum.fuel.network/t/is-this-the-right-way-to-create-abstract-contract-for-inheritiance/7350 "2024-12-13T09:19:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![eesheng](https://avatars.discourse-cdn.com/v4/letter/e/2bfe46/32.png) [@eesheng](https://forum.fuel.network/u/eesheng)\
**Post date:** [December 13, 2024, 9:19am UTC](https://forum.fuel.network/t/is-this-the-right-way-to-create-abstract-contract-for-inheritiance/7350/1 "2024-12-13T09:19:10Z")

</div>

In Sway, you can define an abstract contract using an ABI and then implement that ABI in another contract. Here’s how you can create two contracts, A and B, where A is abstract and B inherits from A and overrides a function.

Not too sure if this is the way in creating abstract contract to inherit it.

### Contract A (Abstract)

Define an abstract contract with a function that returns 0:

```sway
// Contract A
contract;

abi ContractA {
    fn return_value() -> u64;
}

impl ContractA for Contract {
    fn return_value() -> u64 {
        0
    }
}

```

### Contract B (Inherits A)

Implement Contract B to inherit from Contract A and override the function to return 1:

```sway
// Contract B
contract;

use contract_a::ContractA;

abi ContractB {
    fn return_value() -> u64;
}

impl ContractB for Contract {
    fn return_value() -> u64 {
        1
    }
}

```

Can we use the same abi? From the post here, using the same ABI would have issue. [Failed to compile contracts without error logs - #8 by naz3eh](https://forum.fuel.network/t/failed-to-compile-contracts-without-error-logs/7259/8)
